简体   繁体   中英

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:

TypeError: a bytes-like object is required, not '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'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM