[問題] pyserial delete 0x7f變成backspace 0x08

看板Python作者 (子集合)時間7年前 (2018/03/02 11:30), 7年前編輯推噓0(005)
留言5則, 3人參與, 7年前最新討論串1/1
我的目的是在serial port中輸入Delete鍵,但是失敗了。 autoboot in 3 seconds (stop with 'Delete' key)... 看到這串字時,按下Delete鍵 這是我的python/pyserial版本 python 3.4.2 pyserial 3.3 Code: import serial sp = serial.Serial(serial_port, 115200, timeout=0.5) sp.write(b'\x7f') 我做個實驗,我用vi寫入一串字,然後游標移到中間 0x7f = 127 = DEL 發現輸入DEL實際上的行為卻變成backspace BS(0x08) 請問我是哪裡有寫錯嗎? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 101.138.125.113 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1519961450.A.F71.html ※ 編輯: subset (101.138.125.113), 03/02/2018 11:33:03

03/02 21:14, 7年前 , 1F
我沒玩這個,但在猜會不會是putty的問題
03/02 21:14, 1F

03/02 22:28, 7年前 , 2F
因為 bs ='\x7f' del='\x1b\x5b\x33\x7e'
03/02 22:28, 2F

03/02 22:29, 7年前 , 3F
在 ubuntu 下 "showkey -a" 可以確認你想要的輸入
03/02 22:29, 3F

03/05 08:37, 7年前 , 4F
成功了 感謝樓上的大大!!del='\x1b\x5b\x33\x7e' 正確
03/05 08:37, 4F

03/05 08:38, 7年前 , 5F
不過我自己在ubuntu下測試 bs='\x08'
03/05 08:38, 5F
文章代碼(AID): #1QcCLgzn (Python)
文章代碼(AID): #1QcCLgzn (Python)