当解码使用默认的 decode() 拨错时,可以设置 errors 参数的值来解决
print(line)
line_de_replace = line.decode(errors='replace').strip() # 用?代替
print("line_de_replace:", line_de_replace)
line_de_ignore = line.decode(errors='ignore').strip() # 直接去除
print("line_de_ignore:", line_de_ignore)
line_de_backslashreplace = line.decode(errors='backslashreplace').strip() # 加 \ 转义
print("line_de_backslashreplace:", line_de_backslashreplace)
# line_de_strict = line.decode(errors='strict') # 默认设置,会报错
# print("line_de_strict:", line_de_strict)
https://blog.csdn.net/symayy/article/details/107250441
https://blog.csdn.net/m0_37374307/article/details/80319146