Skip to content
This repository has been archived by the owner on Jan 9, 2022. It is now read-only.

UnicodeEncodeError: 'gbk' codec can't encode character '\u2022' in position 9: illegal multibyte sequence #26

Open
zookar opened this issue Dec 13, 2018 · 1 comment

Comments

@zookar
Copy link

zookar commented Dec 13, 2018

下载课程大纲时出现编码错误

网站:中国大学MOOC

课程地址:https://www.icourse163.org/course/ZJU-93001?tid=1003013004

问题描述:

6.2 图的遍历(4小节共22:22)
【视频】6.2.1 图的遍历 - DFS (6:43)
python.exe : Traceback (most recent call last):
所在位置 行:1 字符: 7

  • python <<<< mooc.py https://www.icourse163.org/course/ZJU-93001?tid=1003013004 -d "L:\MOOCs"

    • CategoryInfo : NotSpecified: (Traceback (most recent call last)::String) [], RemoteException
    • FullyQualifiedErrorId : NativeCommandError

    File "mooc.py", line 87, in
    main()
    File "mooc.py", line 62, in main
    icourse163.start(args.url, config)
    File "L:\course-crawler-master\mooc\icourse163.py", line 175, in start
    get_resource(term_id)
    File "L:\course-crawler-master\mooc\icourse163.py", line 106, in get_resource
    outline.write(lesson[1], counter, 1)
    File "L:\course-crawler-master\mooc\utils.py", line 191, in write
    print('%s%s%s' % (' ' * level, Outline.res_type[sign], string))
    UnicodeEncodeError: 'gbk' codec can't encode character '\u2022' in position 9: illegal multibyte sequence

    【视频】6.2.2 图的遍历 - BFS (3:27)
    【视频】6.2.3 图的遍历 - 为什么需要两种遍历 (4:03)
    【视频】6.2.4 图的遍历 - 图不连通怎么办 (8:09)
    【文档】6.2 图的遍历-讲义
    【富文本】C语言代码:DFS-邻接表存储
    【富文本】C语言代码:BFS-邻接矩阵存储

我临时在utils.py的191行插入了:

string = string.encode('GBK','ignore').decode('GBk')

问题暂时解决了

@Aster-the-Med-Stu
Copy link

这种情况应该 chcp 65001 就能解决,因为 Windows 中文系统默认编码为 GBK……

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

No branches or pull requests

2 participants