【发布时间】:2026-01-22 05:35:02
【问题描述】:
dct = {1:'James', 2:'Alex', 3:'Thomas'}
if dct == 'James':
print('There is a James in the dictionary.')
else:
print("There is no James.")
我似乎无法弄清楚为什么这个 if-else 语句不起作用,我知道它很小,但我一直得到错误的输出。有谁知道为什么?我的字典有问题吗?感谢您的帮助!
【问题讨论】:
-
{1:'James', 2:'Alex', 3:'Thomas'}与'James'不同。
标签: python-3.x