DIYer22 / boxx

Tool-box for efficient build and debug in Python. Especially for Scientific Computing and Computer Vision.
492 stars 39 forks source link

运行heatmap显示'gbk' codec can't decode byte 0xa5 #6

Closed zhxsking closed 5 years ago

zhxsking commented 5 years ago

用简单的代码运行heatmap报错: File "D:\installapp\Anaconda3\lib\site-packages\boxx\tool\toolSystem.py", line 242, in heatmap code = f.read() UnicodeDecodeError: 'gbk' codec can't decode byte 0xa5 in position 233: illegal multibyte sequence 将此行加上utf8读取则继续报错: File "D:\installapp\Anaconda3\lib\site-packages\boxx\tool\toolSystem.py", line 243, in heatmap code = code.decode('ascii','replace').replace('\ufffd','$?') AttributeError: 'str' object has no attribute 'decode'

DIYer22 commented 5 years ago

你的 .py 代码的编码格式是 gbk 还是 utf8 ?

windows 下默认新建文本都是 gbk 编码, 如果是 gbk, 推荐把代码重新转换为 utf8 的编码. 因为 utf8 更通用, 和 python 生态更兼容

zhxsking commented 5 years ago

是utf8的,我在spyder下写的,文件行首有# -- coding: utf-8 --