Created
May 23, 2015 12:48
-
-
Save pigletfly/ad1793b451d9e31bd328 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# 2.如遇到 UnicodeEncodeError: 'ascii' codec can't encode characters in position 22-25: ordinal not in range(128) | |
# 增加如下3行 | |
import sys | |
reload(sys) | |
sys.setdefaultencoding('utf-8') | |
from pyquery import PyQuery as pq | |
# 要把读出的内容转成unicode再存为PyQuery对象 | |
# input_file = open(file).read() | |
input_file = unicode(open(file).read(), 'utf-8') | |
source = pq(input_file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment