How to solve UnicodeDecodeError in Python 3.6?

前端 未结 5 1900
花落未央
花落未央 2021-01-02 15:58

I am switched from Python 2.7 to Python 3.6.

I have scripts that deal with some non-English content.

I usually run scripts via Cron and also in Terminal.

5条回答
  •  时光说笑
    2021-01-02 16:43

    Python 3 (including 3.6) is already Unicode supported. Here is the doc - https://docs.python.org/3/howto/unicode.html

    So you don't need to force Unicode support like Python 2.7. Try to run your code normally. If you get any error reading a Unicode text file you need to use the encoding='utf-8' parameter while reading the file.

提交回复
热议问题