我是靠谱客的博主 拼搏荷花,这篇文章主要介绍python exe运行报 编码错误_python中编码发生错误。,现在分享给大家,希望可以做个参考。

linux环境下发生编码错误。windows下正常。

linux下已经在命令行改过编码格式,LANG=zh_CN.UTF-8

UnicodeEncodeError: 'latin-1' codec can't encode characters in position 4-6: ordinal not in range(256)

最前面已经有 # -- coding:utf-8 --

这里写的是读取本地excel表格的表名。表名有数字和汉字。是在print的时候报错。

excel_files = get_excel_files(config.get_standard_template_files())#os.walk获得excel文件

standard_template_infos = {}

for file in excel_files:

wb = xlrd.open_workbook(file)

sheet_names = wb.sheet_names()

for sheet_name in sheet_names:

standard_template_id = get_standard_template_id(sheet_name)

if not standard_template_id:

print '请检查文件【%s】中的sheet页面【%s】。' % (file, sheet_name)

continue

sheet = wb.sheet_by_name(sheet_name)

point_codes = []

nrows = sheet.nrows

if nrows <= 2:

continue

print sheet_name

def get_standard_template_id(sheet_name):#在这个函数中报错

pattern = u'^(d{5})'

match = re.match(pattern, sheet_name)

if match is not None:

code = sheet_name[0:5]

return code

else:

print sheet_name#在这里报错

return None

linux下python版本2.7.3.报错,

windows下python版本 2.7.13正常运行

求指教

最后

以上就是拼搏荷花最近收集整理的关于python exe运行报 编码错误_python中编码发生错误。的全部内容,更多相关python内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(99)

评论列表共有 0 条评论

立即
投稿
返回
顶部