Reputation: 13
i have a problem with a string. This is the code:
if x.find("Sensor")!=-1 :
The error that comes out to me is the following:
if x.find("Sensor")!=-1 :
TypeError: argument should be integer or bytes-like object, not 'str'
I think I need to convert the string to binary. Do you have any idea how to do it?
Thank you all
Upvotes: 1
Views: 8564
Reputation: 29
You need to check if you are analyzing a string or a byte object. If it is a byte object you just decode it, example:
element = b'Content to be searched'
string_element = element.decode('UTF-8')
string_element.find('word you are looking for')
Upvotes: 2
Reputation: 71580
It means your string is a bytes object, so try:
if x.find(b"Sensor")!=-1 :
Upvotes: 6