data='''cat /proc/cpuinfo
system type : CUST_CPF6100 (CN6120p1.1-800-AAP)
processor : 0
cpu model : Cavium Octeon II V0.1
BogoMIPS : 1600.00
wait instruction : yes
microsecond timers : yes
tlb_entries : 128
extra interrupt vector : yes
hardware watchpoint : yes, count: 2, address/irw mask: [0x0ffc, 0x0ffb]
ASEs implemented :
shadow register sets : 1
kscratch registers : 3
core : 0
VCED exceptions : not available
VCEI exceptions : not available
/usr/local/components # '''
tmp_list = data.split('\n')
tmp_list.remove(tmp_list[0])
tmp_list.remove(tmp_list[-1])
mark = '\n'.join(tmp_list)
print mark
在使用telnetlib来读写命令的时候,有时候会出现这样的情况,
输出的命令有很多并不是我们想要的,我们需要把返回字符串的头和尾去掉。
示例代码如上面:
打印信息为
system type : CUST_CPF6100 (CN6120p1.1-800-AAP)
processor : 0
cpu model : Cavium Octeon II V0.1
BogoMIPS : 1600.00
wait instruction : yes
microsecond timers : yes
tlb_entries : 128
extra interrupt vector : yes
hardware watchpoint : yes, count: 2, address/irw mask: [0x0ffc, 0x0ffb]
ASEs implemented :
shadow register sets : 1
kscratch registers : 3
core : 0
VCED exceptions : not available
VCEI exceptions : not available
