Des*_*ura 2 python format dictionary if-statement keyerror
我还是Python的初学者,我想知道为什么:
dict = {}
dict[0] = '123'
a = 0
if dict["{}".format(a)]["{}".format(a)] == '1':
print('True')
Run Code Online (Sandbox Code Playgroud)
给我一个关键错误'0'但不是这个:
dict = {}
dict[0] = '123'
if dict[0][0] == '1':
print('True')
Run Code Online (Sandbox Code Playgroud)
提前致谢.
| 归档时间: |
|
| 查看次数: |
17012 次 |
| 最近记录: |