4 ms·
Not sure what you're talking about mate, on Python 3.6: >>> "hello world".decode("utf-8") Traceback (most recent call last): File "<stdin>", line
by guitarbill 8y ago
Not sure what you're talking about mate, on Python 3.6:
>>> "hello world".decode("utf-8")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'str' object has no attribute 'decode'
>>> b"hello world".encode("utf-8")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'bytes' object has no attribute 'encode'
- burntsushi 8y agoThat's good. I guess it's only in Python 2 then.
- luckystarr 8y agoIn Python 2 it works almost the same, except you only get an error when encoding/decoding doesn't work out. So I see this as an improvement.
- dcbadacd 8y agoI'm pretty sure I tripped up on an issue like this on python 3.7 where I double encoded or decoded something. Can't recall the exact case but it was confusing for sure.