python SyntaxError: Non-ASCII character '\xe6' in file

【1】python程序執行報錯python

報錯:SyntaxError: Non-ASCII character '\xe6' in file /tmp/788580473/main.py on line 7, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details 編碼

現象以下圖:spa

【2】解決方案code

經分析,屬於編碼問題(代碼中含有中文),須要添加utf-8編碼格式:blog

1 #coding=utf-8

正常效果以下圖:
utf-8

經驗證,python2.0會報相似的錯誤,python3.0正常。class

Good Good Study, Day Day Up.coding

順序 選擇 循環 總結file

相關文章
相關標籤/搜索