UnicodeEncodeError: ‘locale’ codec can’t encode character ‘\u5e74’ in position 2: encoding error

2022年7月7日10:15:29

strftime()函数报错

UnicodeEncodeError: 'locale' codec can't encode character '\u5e74' in position 2: encoding error

我的strftime()函数调用代码如下:

time.strftime('%Y年%m月%d日')

修改为

time.strftime('%Y{y}%m{m}%d{d}).format(y='', m='', d='日')

问题解决,记录一下。

  • 作者:程裕强
  • 原文链接:https://blog.csdn.net/chengyuqiang/article/details/102775385
    更新时间:2022年7月7日10:15:29 ,共 216 字。