我正在尝试将python2代码移植到Python3。 下面的代码在python 2中运行得很好。zones = [i.encode("ascii", "ignore").strip(" \"\'")
for i in resque_zone]但在Python3中,我得到了著名的"a bytes-like object is required,not str“。
在我的系统上,一段适用于Python2的代码不适用于Python3。latin-1' codec can't encode character '\u2212' in position 12688: ordinal not in range(256)
这个字符确实不是ASCII码,但是我不明白为什么当文件看起来是一个正确的latin-1 -8文件,并且编码在头文件中时,QXmlStreamReader还希望找到一个ASCII码。