>>> "%(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'
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
换成%d再试试看
KeyError应该类型错误。
我试过
还是报原来的错误:
看了这个
%(1)s中的1是为了匹配key值的。