Kashgari icon indicating copy to clipboard operation
Kashgari copied to clipboard

[Question] 模型保存出错

Open ppvv6688 opened this issue 3 years ago • 6 comments

You must follow the issue template and provide as much information as possible. otherwise, this issue will be closed. 请按照 issue 模板要求填写信息。如果没有按照 issue 模板填写,将会忽略并关闭这个 issue

Check List

Thanks for considering to open an issue. Before you submit your issue, please confirm these boxes are checked.

You can post pictures, but if specific text or code is required to reproduce the issue, please provide the text in a plain text format for easy copy/paste.

Environment

  • OS [e.g. Mac OS, Linux]:win10
  • Python Version:python3.7
  • requirements.txt:
[Paste requirements.txt file here]

Question

model.save() 小白做这个,出现以下错误,请问怎么解决?感谢!

File "D:\ProgramData\Anaconda3\lib\site-packages\kashgari\tasks\abs_task_model.py", line 84, in save f.write(json.dumps(self.to_dict(), indent=2, ensure_ascii=False))

UnicodeEncodeError: 'gbk' codec can't encode character '\xa1' in position 98690: illegal multibyte sequence

ppvv6688 avatar Feb 07 '21 05:02 ppvv6688

f.write() 试着用encoding='utf8',如果你的文件是用utf8格式读的,写的时候因为默认是gbk,所以可能会出错

Allen-dududu avatar Mar 26 '21 04:03 Allen-dududu

f.write()试着用encoding ='utf8',如果你的文件是用utf8格式读的,写的时候因为只是是gbk,所以可能会出错

去包里源文件修改么?我不太会啊

ppvv6688 avatar Mar 26 '21 04:03 ppvv6688

f.write()试着用encoding ='utf8',如果你的文件是用utf8格式读的,写的时候因为只是是gbk,所以可能会出错

去包里源文件修改么?我不太会啊

f.write(json.dumps(self.to_dict(), indent=2, ensure_ascii=False), encoding ='utf8' )

Allen-dududu avatar Mar 26 '21 06:03 Allen-dududu

谢谢

ppvv6688 avatar Apr 01 '21 08:04 ppvv6688

新版本应该已修复,在测试看看~

BrikerMan avatar Jul 07 '21 02:07 BrikerMan

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 16 '22 03:04 stale[bot]