How to fix: “UnicodeDecodeError: 'ascii' codec can't decode byte”

前端 未结 19 1547
谎友^
谎友^ 2020-11-22 01:21
as3:~/ngokevin-site# nano content/blog/20140114_test-chinese.mkd
as3:~/ngokevin-site# wok
Traceback (most recent call last):
File \"/usr/local/bin/wok\", line 4, in
         


        
相关标签:
19条回答
  • 2020-11-22 02:19

    I had the same problem but it didn't work for Python 3. I followed this and it solved my problem:

    enc = sys.getdefaultencoding()
    file = open(menu, "r", encoding = enc)
    

    You have to set the encoding when you are reading/writing the file.

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