在此之前,我使用以下代码解决了ASCII与UTF-8编码的问题。
import sys
reload(sys)
sys.setdefaultencoding('utf8')`或者有时候这就足够了:
html = html.decode("utf-8")现在的区别是,在我的regex函数中,我直接在代码中使用“”(在所有数据/变量之前)。程序也会崩溃,即使我用“输出”来评论这个部分。
SyntaxError: Non-ASCII character '\xc3' in file bla/bla/bla.py on line 75, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details折叠线造成了以下问题:
def adjust_city_name(name):
matchesfound = re.search('((Stadt|Große Kreisstadt)\s)?(.*)', name, re.IGNORECASE)有什么办法可以解决这个问题呢?
全面回溯:
Traceback (most recent call last):
File "bla/bla/crwl.py", line 2, in <module>
from linkParser import *
File "bla/bla/linkParser.py", line 2, in <module>
from helpFunctions import *
File "bla/bla/helpFunctions.py", line 75
SyntaxError: Non-ASCII character '\xc3' in file bla/bla/helpFunctions.py on line 75, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details发布于 2018-04-20 11:46:23
https://stackoverflow.com/questions/49940890
复制相似问题