在Python中,可以通过字典的键来获取对应的值,并使用print()函数打印出来。可以使用以下方法打印字典的值:
my_dict = {"name": "Alice", "age": 20, "city": "Beijing"}
for key in my_dict:
print(my_dict[key])
输出:
Alice
20
Beijing
my_dict = {"name": "Alice", "age": 20, "city": "Beijing"}
for value in my_dict.values():
print(value)
输出:
Alice
20
Beijing
my_dict = {"name": "Alice", "age": 20, "city": "Beijing"}
for key, value in my_dict.items():
print(value)
输出:
Alice
20
Beijing