Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
zhxsking opened this issue Feb 25, 2019 · 2 comments
Closed

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

zhxsking opened this issue Feb 25, 2019 · 2 comments

Comments

@zhxsking
Copy link

用简单的代码运行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
Copy link
Owner

DIYer22 commented Feb 25, 2019

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

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

@DIYer22 DIYer22 closed this as completed Feb 25, 2019
@zhxsking
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants