SyntaxError: Non-ASCII character '\xe8' in file 05.py on line 4, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details這是因為註解裡面包含中文,但確定此script是用UTF-8儲存的。參考了《PEP 263 -- Defining Python Source Code Encodings》一文,了解在程式最前面,#!/usr/bin/env 這一行後面要宣告這個script是以哪種編碼方式儲存,如下:
- # -*- coding: utf-8 -*-
- # -*- coding: latin-1 -*-
- # -*- coding: iso-8859-15 -*-
- # -*- coding: ascii -*-
_EOF_
沒有留言:
張貼留言