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

前端 未结 19 1955
谎友^
谎友^ 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:09

    In some cases, when you check your default encoding (print sys.getdefaultencoding()), it returns that you are using ASCII. If you change to UTF-8, it doesn't work, depending on the content of your variable. I found another way:

    import sys
    reload(sys)  
    sys.setdefaultencoding('Cp1252')
    

提交回复
热议问题