Skip to content

Instantly share code, notes, and snippets.

@alan-w-255
Last active March 31, 2017 05:37
Show Gist options
  • Save alan-w-255/b003350a3dafc895269f3b9f0b5b5324 to your computer and use it in GitHub Desktop.
Save alan-w-255/b003350a3dafc895269f3b9f0b5b5324 to your computer and use it in GitHub Desktop.
python codecs 解决文件中文编码错误
#%%
import codecs, sys
import json
f = codecs.open('crawl.json', 'r', 'utf-8','ignore')
data = json.load(f)
for x in data:
try:
print(x['mblog_text'])
except KeyError:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment