在准备考计算机二级的python,这是给出的答案,不知道为什么会报错
```python
import time
t = time.localtime()
print(time.strftime('%Y年%m月%d日%H时%M分%S秒',t))
###### 运行结果及报错内容
```python
Traceback (most recent call last):
File "D:/2021-11-18创建python/python模考答案/10.py", line 11, in <module>
print(time.strftime('%Y年%m月%d日%H时%M分%S秒',t))
UnicodeEncodeError: 'locale' codec can't encode character '\u5e74' in position 2: Illegal byte sequence
不能在strftime里面写中文, 用format去替换里面的。 如果能用请采纳
import time
t = time.localtime()
print(time.strftime('%Y{Y}%m{m}%d{d}%H{H}%M{M}%S{S}',t).format(Y='年',m='月',d='日',H='时',M='分',S='秒'))
可以运行呀,把上面那个python行删了就好了