Skip to content
This repository has been archived by the owner on Mar 20, 2019. It is now read-only.

提一个bug #4

Open
wby238 opened this issue Aug 6, 2017 · 2 comments
Open

提一个bug #4

wby238 opened this issue Aug 6, 2017 · 2 comments

Comments

@wby238
Copy link

wby238 commented Aug 6, 2017

如果保存settings.conf时用了gb2312,运行icourse163-dl时会提示:

Traceback (most recent call last):
  File "G:\git\cn-mooc-dl\icourse163-dl.py", line 215, in <module>
    main(course_url)
  File "G:\git\cn-mooc-dl\icourse163-dl.py", line 11, in main
    config = model.config("settings.conf", "icourse163")
  File "G:\git\cn-mooc-dl\model\config.py", line 36, in load_config
    config.read(config_file, encoding="utf-8-sig")
  File "C:\Program Files\Python36\lib\configparser.py", line 697, in read
    self._read(fp, filename)
  File "C:\Program Files\Python36\lib\configparser.py", line 1015, in _read
    for lineno, line in enumerate(fp, start=1):
  File "C:\Program Files\Python36\lib\codecs.py", line 321, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
  File "C:\Program Files\Python36\lib\encodings\utf_8_sig.py", line 69, in _buff
er_decode
    return codecs.utf_8_decode(input, errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xca in position 359: invali
d continuation byte
@Rhilip
Copy link
Owner

Rhilip commented Aug 6, 2017

这个。。
默认情况下应该时不会对已有的配置文件改编码的吧。而且现在也多用的时utf-8。
到时候会改成usersettings.py的形式来获取cookies等信息(弃用configparser),新的还只是开了个坑,不知道什么时候能push上来。。

@wby238
Copy link
Author

wby238 commented Aug 6, 2017

我也没改过对应的编码,只是出问题后去查一下发现settings.conf的编码是gb2312,原因可能是因为你提供的conf的内容全部是ascii,编辑器就默认以ansi的方式打开,再加上我在修改conf的保存路径时用了中文,最后编辑器就默认以ansi的编码保存,结果就变成这样了……或许你可以在注释上面放几个中文字符后以utf-8的方式保存再push。

顺便提个建议:
能不能在创建目录或者文件时在名字前加上序号?毕竟中文数字根本没法排序,而且一些课程章节连中文序号也没有……或者顺便写一份课程的结构当作目录。

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