import time print(time.strftime('%Y年%m月%d日 %H時%M分%S秒'))
執行上面代碼會報錯 UnicodeEncodeError: 'locale' codec can't encode character '\u5e74' in position 2: Illegal byte sequencespa
解決方式:code
time.strftime('%Y{y}%m{m}%d{d} %H{h}%M{f}%S{s}').format(y='年',m='月',d='日',h='時',f='分',s='秒')