我的代码有问题,所以请谁能帮助我?
b'Filesystem'
b'Size'
b'Used'
b'Avail'
b'Use%'
b'Mounted'
b'on'
b'/dev/mapper/rhel-root
b'17G'
b'7.7G'
b'9.4G'
b'46%'
b'/'
b'devtmpfs'
b'15G'
b'0'
b'15G'
b'0%'
我希望我的代码看起来像这样:
Filesystem Size Used Avail Use% Mounted on
/dev/abd/abd 10G 93M 10G 1% /
devtmpfs 63G 0 63G 0% /dev
tmpfs 63G 0 63G 0% /dev/shm
tmpfs 63G 553M 63G 1% /run
tmpfs 63G 0 63G 0% /sys/fs/cgroup
/dev/mapper/rhel-usr 10G 1.2G 8.9G 12% /usr
/dev/vda1 1014M 139M 876M 14% /boot
/dev/mapper/xxx-xxx 10G 158M 9.9G 2% /home
/dev/mapper/rhel-tmp 5.0G 33M 5.0G 1% /tmp
/dev/mapper/rhel-var 10G 570M 9.5G 6% /var
/dev/mapper/vg--prd-lv--prd 2.0T 1.8T 256G 88% /abcd
/dev/mapper/xxxxxxxxxxxxxxxxxxxxxxxx 50G 2.3G 48G 5% /usr/openv
tmpfs 13G 0 13G 0% /run/user/0
tmpfs 13G 0 13G 0% /run/user/1001
================================================ ==================
我正在使用paramiko连接到服务器,但是输出就像列表一样,所以我想要这样:
stdin, stdout, stderr =ssh.exec_command('df -h')
outp=stdout.read()
data=[outp]
for col in data[0].split():
print(col)
答案 0 :(得分:0)
您似乎想要在data
数组中逐行输出,然后将每个数组元素(即line)分成几列。为此,请替换
outp=stdout.read()
data=[outp]
使用
data = stdout.readlines()