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

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

如果从ASCII码中使用find() 方法会抛出异常。

 这时候需要在代码里面贴一下如下的代码

import sys

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

然后就可以愉快使用find了。

原文地址:https://www.cnblogs.com/cindy-2014/p/7646427.html