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

fix api change 20170422 #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lxyjscz
Copy link
Contributor

@lxyjscz lxyjscz commented Apr 22, 2017

No description provided.


# address to possible UnicodeDecodeError for Chinese Characters
reload(sys)
sys.setdefaultencoding('utf8')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's not a very good way to deal with decode error in Python 2.
The data can be first decoded to unicode and then encode to utf-8 like following code.
code = code.decode('utf-8')
s = json.loads('{"code": "%s"}' % code)
...
f.write(s['code'].encode('utf-8'))

@tecton tecton changed the title fix api change 20140422 fix api change 20170422 Apr 24, 2017
Copy link
Owner

@tecton tecton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! And please change the method to deal with chinese characters.

@github-staff github-staff deleted a comment May 27, 2024
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