Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python错误:UnicodeDecodeError_Python_Unicode_Utf - Fatal编程技术网

Python错误:UnicodeDecodeError

Python错误:UnicodeDecodeError,python,unicode,utf,Python,Unicode,Utf,我有一个python脚本,其中有一行: string = student['name'] + "\t" + student['issueDate'] + "\n" 通过脚本的观察结果之一是À(在学生['name'])并且代码总是在这一行中崩溃,并出现错误: UnicodeDecodeError:“ascii”编解码器无法解码位置0中的字节0xff:序号不在范围内(128) 有简单的解决办法吗?我正在考虑在代码的这个阶段清理字符串。python的哪个版本?学生[name']来自哪里?看起来是从带

我有一个python脚本,其中有一行:

string = student['name'] + "\t" + student['issueDate'] + "\n"
通过脚本的观察结果之一是
À
(在
学生['name']
)并且代码总是在这一行中崩溃,并出现错误:

UnicodeDecodeError:“ascii”编解码器无法解码位置0中的字节0xff:序号不在范围内(128)


有简单的解决办法吗?我正在考虑在代码的这个阶段清理字符串。

python的哪个版本?学生[name']来自哪里?看起来是从带有Microsoft BOM表(字节顺序标记)的文件的开头读取的。可能是这个文件应该用编码打开。
print(repr(student['name'))
会很有趣。所以要打印(sys.version)。确保这一行正好是打印(repr(student['issueDate'))也很有趣。在我看来,似乎您需要
student['name']
student['issueDate']
中的一个类型为
unicode
,另一个类型为
str
,才能实现此效果。