1. 程式人生 > >macOS解決sublime text3執行python3報:UnicodeEncodeError: 'ascii' codec can't encode characters in position

macOS解決sublime text3執行python3報:UnicodeEncodeError: 'ascii' codec can't encode characters in position

問題背景:macOS剛裝上python3和sublime test,匯入原來在windows上寫的python指令碼(在windows上執行正常),執行後報錯UnicodeEncodeError: 'ascii' codec can't encode characters in position

解決辦法:

修改Sublime Text3中的設定,Preferences > Browse Packages > User > Python3.sublime-build,如果不存在這個檔案,可以通過新建編譯系統儲存為這個檔案,在該檔案中加上一句:"env": {"LANG": "en_US.UTF-8"}。檔案內容如下: