2019-09-02 | 50095

字典

要确定一个键是否在字典中,就像在列表中一样

nums = {
  1: "one",
  2: "two",
  3: "three",
}
print(1 in nums)
print("three" in nums)
print(4 not in nums)

结果

True
False
True

0

发表评论

    评价:
    Rich Text Editor
    最新评论