再向文件写入中文字符串会出现这个问题。即使在开头添加了# -- coding: utf-8 --也不行。 解决办法: import sys reload(sys) sys.setdefaultencoding( “utf-8” ) 这样可以成功运行。