1. 程式人生 > >運行python出現 SyntaxError: Non-ASCII character 'xe6' in file /Users/finup/Documents/python_project/test.py 解決辦法

運行python出現 SyntaxError: Non-ASCII character 'xe6' in file /Users/finup/Documents/python_project/test.py 解決辦法

分享圖片 test 錯誤 必須 documents 由於 utf error: utf-8

使用pycharm運行程序時出現以下錯誤

技術分享圖片

這個錯誤主要是由於python2的編碼默認是ASCII,你的文件裏有中文就必須要用utf-8編碼,只要在文件需要在文件開頭標註

#coding=utf-8
如下所示:

技術分享圖片

運行python出現 SyntaxError: Non-ASCII character '\xe6' in file /Users/finup/Documents/python_project/test.py 解決辦法