问题
I am trying to send control + c command in python using telnetlib library. Currently I am doing
tn.write('^]')
But the code above doesn't seem to work. Any clue on What I should use?
回答1:
Try ASCII characters of control+c
to the telnet connection below:-
tn.write('\x03')
回答2:
ctrl+a = decimal 1
ctrl+b = decimal 2
ctrl+c = decimal 3
and so on.. to
ctrl+x = decimal 24
ctrl+y = decimal 25
ctrl+z = decimal 26
escape = 27 etc
Still, for those who will need this in the future
Arrow keys are (3 bytes, decimal)
UP ARROW is 27,91,65 (ESC,'[',A)
DOWN ARROW is 27,91,66 (ESC,'[',B)
RIGHT ARROW is 27,91,67 (ESC, '[',C)
LEFT ARROW is 27,91,68 (ESC, '[',D)
来源:https://stackoverflow.com/questions/26183298/how-do-i-send-telnetlib-control-c-command-in-python