当我打印下列信息时它看起来非常难看。 文本显示非常长,您无法真正阅读它。Python输出格式
代码:
import psutil
print("Disk: ", psutil.disk_partitions())
我得到的输出是:
Disk: [sdiskpart(device='C:\\', mountpoint='C:\\', fstype='NTFS', opts='rw,fixed'), sdiskpart(device='D:\\', mountpoint='D:\\', fstype='', opts='cdrom'), sdiskpart(device='E:\\', mountpoint='E:\\', fstype='', opts='cdrom'), sdiskpart(device='F:\\', mountpoint='F:\\', fstype='NTFS', opts='rw,fixed'), sdiskpart(device='H:\\', mountpoint='H:\\', fstype='NTFS', opts='rw,removable')]
在一个长行!有没有办法来过滤输出或在多行显示它?
谢谢你帮助我:)
[pprint(https://docs.python.org/3/library/pprint.html)是你的朋友。 – miku