Skip to content

fix: 修复中文编码导致保存docx失败BUG#1

Open
broholens wants to merge 1 commit intokenley2021:masterfrom
broholens:master
Open

fix: 修复中文编码导致保存docx失败BUG#1
broholens wants to merge 1 commit intokenley2021:masterfrom
broholens:master

Conversation

@broholens
Copy link
Copy Markdown

Traceback (most recent call last):
File "swcr.py", line 285, in
main()
File "C:\Users\zz\Desktop\tmp\swcr\venv\lib\site-packages\click\core.py", line 1137, in call
return self.main(*args, **kwargs)
File "C:\Users\zz\Desktop\tmp\swcr\venv\lib\site-packages\click\core.py", line 1062, in main
rv = self.invoke(ctx)
File "C:\Users\zz\Desktop\tmp\swcr\venv\lib\site-packages\click\core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\zz\Desktop\tmp\swcr\venv\lib\site-packages\click\core.py", line 763, in invoke
return __callback(*args, **kwargs)
File "swcr.py", line 279, in main
writer.write_file(file)
File "swcr.py", line 168, in write_file
for line in fp:
UnicodeDecodeError: 'gbk' codec can't decode byte 0xa8 in position 239: illegal multibyte sequence

@zhuochengs
Copy link
Copy Markdown

zhuochengs commented Jul 31, 2023

我使用 pip install swcr 安装的还是会报错,

可以把 swcr.py 的 167 行 替换成 :
with open(file, mode='r', encoding='utf-8') as fp:
可能因为我是 3.8.10的原因

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

Successfully merging this pull request may close these issues.

2 participants