python3datetime.datetime.strftime
无法接受 utf-8 字符串格式
我所做的是::
# encoding: utf-8
import datetime
f = "%Y年%m月%d日"
now = datetime.datetime.now()
print( now.strftime(f) )
我得到的是:
D:\pytools>python a.py
Traceback (most recent call last):
File "a.py", line 6, in <module>
print( now.strftime(f) )
UnicodeEncodeError: 'locale' codec can't encode character '\u5e74' in position 2
: Illegal byte sequence
为什么以及如何解决这个问题?