>>> "%(1)s" % {1:'a',2:'b'}
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: '1'
下面这个就可以,为什么?
>>> "%(1)s" % {'1':'a','2':'b'}
'a'
阿神2017-04-17 15:37:57
KeyError は typeError である必要があります。
引き続き元のエラーを報告します:
リーリーこの %(1)s
の 1
は key
の値と一致することがわかりました。