[英]Send byte through Telnet in Python
In a Python script, I need to send a single byte through Telnet, with value 0x06, for example. 在Python脚本中,我需要通过Telnet发送单个字节,例如,值为0x06。 However, the write function from
telnetlib
( Telnet.write(buffer)
) only takes strings as argument. 然而,从写功能
telnetlib
( Telnet.write(buffer)
)只需要字符串作为参数。
The conversion using str(0x06)
does not work, as its output converts the number to an array of chars, while what I want is a char whose value is 0x06. 使用
str(0x06)
的转换不起作用,因为其输出将数字转换为chars数组,而我想要的是一个char,其值为0x06。
So basically, how does one send a single byte through Telnet using Python? 因此,基本上,一个人如何使用Python通过Telnet发送单个字节?
You can use: 您可以使用:
Telnet.write( chr(27) )
or 要么
Telnet.write( "\x1b" )
to write one single byte for instance. 例如写一个字节。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.