如果文件名,路径名称,字符串中含有中文汉字,文件头加上这个:

#!/usr/bin/python
#-*- coding:cp936 -*-

 

例如:

#!/usr/bin/python
#-*- coding:cp936 -*-
file = 'E:/_申请/横向/'