Let's pretend that
n = u"Tübingen" repr(n)
The first of the following files throws
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 82: ordinal not in range(128)
When I execute n.encode('utf8')
, it works.
The second works flawlessly in both cases.
# Python File 1
# Python File 2
Since the documentation recommends using format()
instead of the %
format operator, I don’t understand why format()
seems more like a handicap. Does format()
only with utf8
strings?
Aufwind
source share