问题描述:python中写了一个程序去读0.htm文件,但是程序一走到:fr= open(“0.htm” ,”r” )就自动崩溃
原因:htm文件中没有指定打开的编码方式,导致错误
ValueError encoding must be one of 'utf_8','big5', or 'gbk'.
解决方法:
import codecs
try:
fr = codecs.open(“0.htm” ,”r” , “utf-8”)
except Exception, ex:
print Exception,”:”,ex