3 ms·
Python 101: str() is dangerous for unicode objects without a specified encoding. Please don't call str() unless you know exactly what encoding you are dealing w
by est 11y ago
Python 101: str() is dangerous for unicode objects without a specified encoding. Please don't call str() unless you know exactly what encoding you are dealing with.
Try it:
$ LC_ALL=en_US.UTF-8 python -c "print str(u'é')"
Traceback (most recent call last):
File "<string>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)