我怎么能stdout.read()解析

时间:2017-08-17 11:09:27

标签: python parsing ssh paramiko

大家好我从stdout.read()获取ipconfig值,但看起来像这些

   **b'PING localhost (127.0.0.1) 56(84) bytes of data.\n64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.106 ms\n64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=1.01 ms\n64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.054 ms\n64 bytes from localhost (127.0.0.1): icmp_seq=4 ttl=64 time=0.055 ms\n64 bytes from localhost (127.0.0.1): icmp_seq=5 ttl=64 time=0.052 ms\n\n--- localhost ping statistics ---\n5 packets transmitted, 5 received, 0% packet loss, time 4000ms\nrtt min/avg/max/mdev = 0.052/0.256/1.014/0.379 ms\n'**

我需要像普通ipconfig那样解析它们我该怎么办?

import paramiko


hostname = '192.168.xx.xxx'
port = 22
username = 'root'
password = 'xxxxxxx'

if __name__ == "__main__":
    paramiko.util.log_to_file('paramiko.log')
    s = paramiko.SSHClient()
    s.load_system_host_keys()
    s.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    s.connect(hostname, port, username, password)
    stdin, stdout, stderr =s.exec_command('ping localhost -c 5')
    print(stdout.read())
    s.close()

0 个答案:

没有答案