假设我有以下代码:
a = 'naïve' # It contains the character ï
b = 'some text that may or may not contain the word we are looking for'
if a in b: #error happens here
print 'success'
我想看看a
是否在b
内,但它显然不知道如何使用非英语标准的unicode字符。它给了我以下错误:
SyntaxError: Non-ASCII character 'xc3' in file app.py on line 10, but no encoding declared
我不知道该做什么或尝试。有线索吗?谢谢你。
将这一行放在文件的顶部:
# -*- coding: utf-8 -*-