Last active
January 26, 2016 11:24
-
-
Save kezabelle/9e271d20f296b04423d5 to your computer and use it in GitHub Desktop.
Gods I hate you python string formatting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> x = u'\u2019' | |
>>> '%s' % x | |
u'\u2019' | |
>>> '%(x)s' % {'x': x} | |
u'\u2019' | |
>>> '{}'.format(x) | |
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 0: ordinal not in range(128) | |
>>> {0!s}'.format(x) | |
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 0: ordinal not in range(128) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment