[英]Python - a bytes like object is required, not str
I'm moving my Twitch bot from Python 2.7 to Python 3.5. 我将Twitch机器人从Python 2.7移到了Python 3.5。 I keep getting the error: a bytes like object is required not 'str'
on the 2nd line of the code below. 我不断收到错误消息:在下面代码的第二行上, 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
try 尝试
data = twitchdata.decode().split(":")[1]
instead of 代替
data = twitchdata.split(":")[1]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.