Created
December 5, 2017 19:48
-
-
Save davidwtbuxton/1ae338bab7833ae4a0b45936b4a3d5d3 to your computer and use it in GitHub Desktop.
python 2 string formatting fun
This file contains hidden or 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
$ python2.7 | |
Python 2.7.14 (default, Sep 22 2017, 00:06:07) | |
[GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)] on darwin | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> value = u'\u0141uk\u0105\u015b\u017a' | |
>>> '%s' % value | |
u'\u0141uk\u0105\u015b\u017a' | |
>>> '{}'.format(value) | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0141' 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