UnicodeDecodeError while using cyryllic

后端 未结 2 708
小鲜肉
小鲜肉 2021-01-21 02:31

I have a module which contains only (it\'s only example. Problem is in much bigger module):

# -*- coding: utf-8 -*-
\"януари\"

While execution

相关标签:
2条回答
  • 2021-01-21 02:39

    That module is not the problem, it seems to be a problem with PyCharm. It apparently reads your file, and assumes it's cp1250, even when it's specified to be utf-8. So that's a bug in PyCharm.

    It should open the file as binary, read the first line to see if it has an encoding, in other case it should assume it to be UTF-8. (Although it should really assume it to be ASCII under Python 2, but UTF-8 is good enough).

    0 讨论(0)
  • 2021-01-21 02:43

    In PyCharm you can specify UTF-8 encoding in Settings (CTRL+ALT+S) | File encodings. That should work.

    0 讨论(0)
提交回复
热议问题