3 ms·
Not sure what you mean. It's the default for a long time now. https://docs.python.org/3/library/stdtypes.html#bytes.decode https://docs.python.org/3/library/std
by viraptor 9y ago
Not sure what you mean. It's the default for a long time now. https://docs.python.org/3/library/stdtypes.html#bytes.decode https://docs.python.org/3/library/stdtypes.html#bytes.decode
`open` also defaults to your system encoding, which is likely utf8 judging from the message.
- singularity2001 9y agoprint(str(b'I am a broken string')) print(str(b'I DONT WANT TO add "UTF-8" everywhere!!','UTF-8')) not quite default!
- orf 9y agoExplicit is better than implicit. The first line isnt a string, it's a collection of bytes, guessing that it's utf8 is not the right thing to do. The encode (or is it decode? I always forget) defaults to utf8, which is what you should be using.
- Siecje 9y agoIt helps me to think encrypt for encode (convert to bytes) and decrypt for decode (convert to text).
- viraptor 9y agoI'm not sure why this example is interesting. You can write: print('I DONT WANT TO add "UTF-8" everywhere!!') And get the same result. Or if you really want to start with bytes: print(b'some string'.decode())