circlelq/yan-yuan-mao-su-cha-shou-ce-old

python output files encoding problem (python输出文件的编码问题)

shuiyantiao opened this issue · 3 comments

I ran circle.py in Windows 10 with Python3.8, and the program did not run properly, and reported Traceback (most recent call last): File ".\circle.py", line 144, in <module> f.write(f2.read()) UnicodeDecodeError: 'gbk' codec can't decode byte 0xa2 in position 10: illegal multibyte sequence.
So it is better to assign output files encoding as UTF-8, for example , with open('index/狸花/狸花' + '.js', 'w', encoding='utf-8') as f:. With these changes, circle.py works properly in Windows 10 with Python3.8.

在Win10+Python3.8下,文件输出时的默认编码为GBK,此时会遇到部分UTF-8字符无法编码的问题,错误信息如上。建议在打开文件时显式指定文件的编码类型为UTF-8,使程序可以正确运行。

感谢您的提醒,我现在把打开文件时都指定文件的编码类型为UTF-8,您可以再检查一下~

经测试,文件编码类型没有问题了。但是脚本中有残留的"出竹"和"花灵灵"用例,建议去除。

经测试,文件编码类型没有问题了。但是脚本中有残留的"出竹"和"花灵灵"用例,建议去除。

这个版本是我自己使用的,需要"出竹"和"花灵灵"用例😂发布使用的版本没有"出竹"和"花灵灵"用例。