字典数据类型.py 266 B

1234567
  1. items_price = {"apple":30, "banana":20, "cherry":15, "date":10}
  2. items_price["banana"] = 25
  3. del items_price["cherry"]
  4. items_price["elderberry"] = 40
  5. print("apple的价格为:", items_price["apple"])
  6. for item, price in items_price.items():
  7. print(f"{item}:{price}")