简体   繁体   English

TypeError:需要一个类似字节的对象,而不是python 3.5中的“ str”

[英]TypeError: a bytes-like object is required, not 'str' in python 3.5

I am learning data scraping in python 3.5 and trying to find the existence of a word on website, i am getting error: 我正在python 3.5中学习数据抓取并尝试在网站上找到单词的存在,但出现错误:

TypeError: a bytes-like object is required, not 'str' TypeError:需要一个类似字节的对象,而不是'str'

 pyladies_source = uReq("http://pyladies.com")
 pyladies_source = pyladies_source.read()
'python' in pyladies_source
pyladies_source = uReq("http://pyladies.com")
pyladies_source = pyladies_source.read()
'python' in str(pyladies_source) # Returns false in this case, at least when I ran it.

All you had to change was casting pyladies_source to a string so you can look for 'python' pyladies_source就是将pyladies_source转换为字符串,以便可以查找'python'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 python 3.5 + aiohttp:TypeError:使用io.BytesIO时需要一个类似字节的对象,而不是'str' - python 3.5 + aiohttp: TypeError: a bytes-like object is required, not 'str' when use io.BytesIO 需要一个类似字节的对象,而不是'str':TypeError - a bytes-like object is required, not 'str' : TypeError TypeError:需要一个类似字节的对象,而不是'str' - TypeError: a bytes-like object is required, not 'str' TypeError:需要一个类似字节的对象,而不是“str” - TypeError: a bytes-like object is required, not 'str' TypeError:需要类似字节的 object,而不是“str”? - TypeError: a bytes-like object is required, not 'str'? python错误TypeError:需要一个类似字节的对象,而不是'str' - python error TypeError: a bytes-like object is required,not 'str' 类型错误:需要一个类似字节的对象,而不是 python 和 CSV 中的“str” - TypeError: a bytes-like object is required, not 'str' in python and CSV Python SocketServer 错误:TypeError:需要类似字节的对象,而不是“str” - Python SocketServer Error : TypeError: a bytes-like object is required, not 'str' TypeError:需要类似字节的对象,而不是'str'-python - TypeError: a bytes-like object is required, not 'str' -python Python 2 到 3 “类型错误:需要类似字节的 object,而不是 'str'” - Python 2 to 3 “TypeError: a bytes-like object is required, not 'str'”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM