python模块locale出错
回答
收藏

python模块locale出错

J
Jenny Zhen
2024-06-28 17:39·浏览量:307
J
Jenny Zhen
发布于 2024-06-28 17:39307浏览

python模块中读取了一个excel,其中有一列是时间,但是格式是XXXX-XX-XX,需要将此列最大日期和最小日子找到。

原来的代码在两台电脑上可以跑,但是有一台电脑会出错unsupported locale setting,不知道要怎么解决

submit_time_series = df.loc[:, '提交时间'].dropna()

locale.setlocale(locale.LC_TIME, 'zh_CN.UTF-8')

min_date = submit_time_series.min().strftime('%m{m}%d{m}').format(m='月', d='日')

max_date = submit_time_series.max().strftime('%m{m}%d{m}').format(m='月', d='日')

locale.setlocale(locale.LC_TIME, '')

尝试过的方案

尝试import locale,出错'locale' codec can't encode character '\u6708' in position 2: encoding error


import locale

locale.setlocale(locale.LC_ALL, 'chinese_simplified')

收藏1
全部回答1
最新
发布回答
回答