Is there a simple way to get rid of junk values that come when you SSH using Python's Paramiko library and fetch output from CLI of a remote machine?
问题 I am using Python's Paramiko library to SSH a remote machine and fetch some output from command-line. I see a lot of junk printing along with the actual output. How to get rid of this? chan1.send("ls\n") output = chan1.recv(1024).decode("utf-8") print(output) [u'Last login: Wed Oct 21 18:08:53 2015 from 172.16.200.77\r', u'\x1b[2J\x1b[1;1H[local]cli@BENU>enable', u'[local]cli@BENU#Configure', I want to eliminate, [2J\x1b[1;1H and u from the output. They are junk. 回答1: It's not a junk. These