简体   繁体   English

Python-需要像对象这样的字节,而不是str

[英]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.

相关问题 Python需要类似字节的对象,而不是'str' - Python a bytes-like object is required, not 'str' python:"\\" in str 需要一个类似字节的对象,而不是 'str' - python:"\" in str a bytes-like object is required, not 'str' TypeError:需要一个类似字节的对象,而不是'str'python - TypeError: a bytes-like object is required, not 'str' python Python 错误:需要类似字节的对象,而不是“str” - Python error:a bytes-like object is required, not 'str' TypeError:需要一个类似字节的对象,而不是 Python 中 Image 命令的“str” - TypeError: a bytes-like object is required, not 'str' for Image command in Python Python TypeError:需要一个类似字节的对象,而不是'str' - Python TypeError: a bytes-like object is required, not 'str' TypeError:需要一个类似字节的对象,而不是'str'python3 - TypeError: a bytes-like object is required, not 'str' python3 python 套接字编程类型错误:不需要像 object 这样的字节 str - python socket programming TypeError: bytes like object is required not str 类型错误:需要类似字节的 object,而不是使用子进程 python 的“str” - TypeError: a bytes-like object is required, not 'str' using Subprocess python TypeError:需要一个类似字节的对象,对于无服务器和Python3来说不是'str' - TypeError: a bytes-like object is required, not 'str' with serverless and Python3
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM