Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

编码好像问题挺多的 #62

Open
lxj0276 opened this issue May 16, 2016 · 4 comments
Open

编码好像问题挺多的 #62

lxj0276 opened this issue May 16, 2016 · 4 comments

Comments

@lxj0276
Copy link

lxj0276 commented May 16, 2016

我在win7,64bit,python2.7.10下运行,遇到汉字的时候都是乱码。。。

@bugmakesprogress
Copy link

你可以将zhihu.py里的验证windows平台的代码删除 因为知乎编码本来就是utf-8
if platform.system() == 'Windows':
file_name = self.get_question().get_title() + "--" + self.get_author().get_user_id() + "的回答.txt".decode(
'utf-8').encode('gbk')
else:
file_name = self.get_question().get_title() + "--" + self.get_author().get_user_id() + "的回答.txt"
print file_name

直接改为 print file_name
注意搜索关键字是windows

能够输出文件名:
现实可以有多美好?--田浩的回答.txt

但是接下来的txt文档就打不开了:
IOError: [Errno 22] invalid mode ('wb') or filename: 'E:\workspace\zhihuhelper\zhihuhelper\text\xe7\x8e\xb0\xe5\xae\x9e\xe5\x8f\xaf\xe4\xbb\xa5\xe6\x9c\x89\xe5\xa4\x9a\xe7\xbe\x8e\xe5\xa5\xbd\xef\xbc\x9f--\xe7\x94\xb0\xe6\xb5\xa9\xe7\x9a\x84\xe5\x9b\x9e\xe7\xad\x94.txt'

@lxj0276
Copy link
Author

lxj0276 commented May 18, 2016

@bugmakesprogress 你这个是解码编码问题了。我的问题已经全部解决了~

@xxllp
Copy link

xxllp commented Jun 14, 2016

感觉有些代码可以重构下,至少设置个默认编码

@birdbaby
Copy link

请问怎么解决的?

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

No branches or pull requests

4 participants