检查某个键是否存在

  1. thisdict = {
  2. "brand": "Porsche",
  3. "model": "911",
  4. "year": 1963
  5. }
  6. if "model" in thisdict:
  7. print("Yes, 'model' is one of the keys in the thisdict dictionary")