locations = {
"headquarters": "New York",
"flagship": "Paris"
}
print(locations)
car_data ={
"brand": "Cadillac",
"year": 2019,
"restoration": ["1990", "2018"],
"rended": False
}
print(car_data)
actor_bio = {
"name": "Bill Murray",
"known for": ["Lost in Translation", "Rushmore"]
}
print(actor_bio["name"]) # 提取键的值
ticket = {
"seat no." : 25,
"first class": False
}
ticket["first class"] = True # 修改键的值
print(ticket)
winner_scores = {
"first":("Ted",50),
"second":("Jess",47)
}
for winner in winner_scores:
print(winner_scores[winner])
winner_scores["third"] = ("Jo", 30) # 向字典中添加内容
print(winner_scores)
personal_data = {
"name": "Mac Miller",
"telephone": "012345567"
}
print("name" in personal_data) # 检查字典中是否有某个键
stock = {
"dresses": 25,
"t-shirts": 50,
"jeans": 1
}
if "jeans" in stock:
stock.pop("jeans") # 在字典中删除键
print(stock)