Python解决问题UnicodeEncodeError: 'ascii' codec can't encode characters in position

直接从使用content=urllib.urlopen(url).read()  返回的内容是ASCII码。url

若是从ASCII码中使用find() 方法会抛出异常。spa

 

 这时候须要在代码里面贴一下以下的代码code

import sys

reload(sys)
sys.setdefaultencoding( "utf-8" )

 

而后就能够愉快使用find了。blog

相关文章
相关标签/搜索