attributeerror: ‘str’ object has no attribute ‘decode’

attributeerror: ‘str’ object has no attribute ‘decode’

The following code in Python 3 will report the above error

print(“Response:”, resp.text.decode(‘unicode_ Solution:
Print (“response:”, resp.text.encode (‘utf-8 ‘). Decode (‘unicode’)_ Escape ‘)
Add. Encode (‘utf-8’) in the middle

Reason for the problem:
in Python 3, a string must be manually specified as a bytecode by encode before it can be decoded

Similar Posts: