2019-09-02 |

字典

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

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

结果

True
False
True

0

发表评论

    评价:
    验证码: 点击我更换图片
    最新评论