python删除“下一行”字符(以\ x1b [1b)的形式出现
我正在通过防火墙通过SSH与Paramiko一起提取输出。 输出是这样显示的:
l = ['Total active sessions : 0\r\x1b[1BActive TCP sessions : 0\r\x1b[1BActive UDP sessions : 0\r\x1b[1BActive ICMP sessions : 0\r\x1b[1B']
我能够使用以下命令将列表分开
for i in l:
i.splitlines()
['Total active sessions : 0', '\x1b[1BActive TCP sessions : 0', '\x1b[1BActive UDP sessions : 0', '\x1b[1BActive ICMP sessions : 0', '\x1b[1B']
,在表中的所有元素中仍出现\ x1b [1b
。我查找了字节字符,这似乎是一个“下一行”字符。无论哪种方式,如何将其从列表中的每个元素中删除?
I am pulling output with paramiko via ssh from a firewall.
The output is showing like this:
l = ['Total active sessions : 0\r\x1b[1BActive TCP sessions : 0\r\x1b[1BActive UDP sessions : 0\r\x1b[1BActive ICMP sessions : 0\r\x1b[1B']
I was able to split the list with the following command
for i in l:
i.splitlines()
['Total active sessions : 0', '\x1b[1BActive TCP sessions : 0', '\x1b[1BActive UDP sessions : 0', '\x1b[1BActive ICMP sessions : 0', '\x1b[1B']
There is still appearing \x1b[1B
in all elements in the table. I looked up the byte character and this appears to be a "Next line" character. Either way, how can I remove this from every element in the list?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试以下操作:
Try this: