[英]Telnetlib read server response without telnet commands
I'm using telnetlib to connect to a remote telnet server and parse it's response, however, all telnetlib's read_*
methods return its raw response - including raw telnet command bytes (starting with 0xFF) - which is undesirable for my purpose. 我正在使用telnetlib连接到远程telnet服务器并解析其响应,但是,所有read_*
的read_*
方法都返回其原始响应-包括原始telnet命令字节(以0xFF开头)-这对我而言是不希望的。
For example, when calling read_all
: 例如,当调用read_all
:
desired output - b'Hello'
所需的输出b'Hello'
output returned by telnetlib - b'\\xff\\xfd\\x18\\xff\\xfdHello'
b'\\xff\\xfd\\x18\\xff\\xfdHello'
返回的输出b'\\xff\\xfd\\x18\\xff\\xfdHello'
Is there a way to make telnetlib exclude those special telnet control bytes from its output? 有没有办法使telnetlib从其输出中排除那些特殊的telnet控制字节?
As far as I can tell from your question you need to convert the string into UTF-8. 据您所知,您需要将字符串转换为UTF-8。 This may be your solution. 这可能是您的解决方案。 https://www.tutorialspoint.com/python/string_decode.htm https://www.tutorialspoint.com/python/string_decode.htm
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.