Just when you thought it was safe to unicode....
>>> unicode(3)
u'3'
>>> unicode(3, errors='replace')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: coercing to Unicode: need string or buffer, int found
If you prefer Python3:
>>> str(3)
'3'
>>> str(3, errors='replace')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: coercing to str: need bytes, bytearray or buffer-like object, int found
Yes, str is really two functions in one. print(str.__doc__) will tell you how it's used.
ReplyDelete