s= datetime.now().strftime(u"%Y年%m月%d日 %H:%M:%S" )
UnicodeEncodeError: 'locale' codec can't encode character '\u5e74' in position 2: encoding error
可行方案:
import locale
from datetime import datetime
locale.setlocale(locale.LC_CTYPE, 'Chinese')
def print_current_time(mark):
s= datetime.now().strftime(u"%Y年%m月%d日 %H:%M:%S" )
print(s)
print_current_time('start')