>>> "%(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'
认证高级PHP讲师
Change to %d and try again
KeyError should be of typeError. I tried
"%(1)s" % {'3': 'a', '2': 'b'}
Still report the original error:
Traceback (most recent call last): File "<stdin>", line 1, in <module> KeyError: '1'
I saw that the %(1)s in this 1 is to match the key value.
%(1)s
1
key
Change to %d and try again
KeyError should be of typeError.
I tried
Still report the original error:
I saw that the
%(1)s
in this1
is to match thekey
value.