spe*_*hta 38 python irc python-3.x twitch
我正在将我的Twitch bot从Python 2.7移植到Python 3.5.我一直收到错误:
a bytes like object is required not 'str'
在下面的代码的第二行.
twitchdata = irc.recv(1204)
data = twitchdata.split(":")[1]
twitchuser = data.split("!")[0]
twitchmsg = twitchdata.split(":")[2]
chat = str(twitchuser) +": "+ str(twitchmsg)
print(chat) #prints chat to console
Run Code Online (Sandbox Code Playgroud)
val*_*tin 51
尝试
data = twitchdata.decode().split(":")[1]
Run Code Online (Sandbox Code Playgroud)
代替
data = twitchdata.split(":")[1]
Run Code Online (Sandbox Code Playgroud)