Skip to content

Instantly share code, notes, and snippets.

  • Save jerzyk/f6f75275156eb48bfa22fe42470380ab to your computer and use it in GitHub Desktop.
Save jerzyk/f6f75275156eb48bfa22fe42470380ab to your computer and use it in GitHub Desktop.
 In [1]  text = u'zażółć gęślą jaźń'
 In [2]  open('test.txt', 'w').write(text)
---------------------------------------------------------------------------
UnicodeEncodeError Traceback (most recent call last)
<ipython-input-2-da71a133970f> in <module>()
----> 1 open('test.txt', 'w').write(text)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 2-5: ordinal not in range(128)
 In [3]  open('test.txt', 'w').write(text.encode('utf-8'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment