简体   繁体   中英

Send byte through Telnet in Python

In a Python script, I need to send a single byte through Telnet, with value 0x06, for example. However, the write function from telnetlib ( Telnet.write(buffer) ) only takes strings as argument.

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.

So basically, how does one send a single byte through Telnet using Python?

You can use:

Telnet.write( chr(27) )

or

Telnet.write( "\x1b" )

to write one single byte for instance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM