python 打印字典换行
时间: 2023-09-13 17:02:52 浏览: 243
python数码管打印
可以通过循环打印每个键值对,并在每个键值对后面加上换行符"\n"来实现字典的换行打印,示例代码如下:
```python
my_dict = {"name": "John", "age": 25, "city": "New York"}
for key, value in my_dict.items():
print(key, ":", value)
print("\n")
```
输出结果:
```
name : John
age : 25
city : New York
```
阅读全文