看板 Python 關於我們 聯絡資訊
我的目的是在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
WunoW: 我沒玩這個,但在猜會不會是putty的問題 03/02 21:14
s860134: 因為 bs ='\x7f' del='\x1b\x5b\x33\x7e' 03/02 22:28
s860134: 在 ubuntu 下 "showkey -a" 可以確認你想要的輸入 03/02 22:29
subset: 成功了 感謝樓上的大大!!del='\x1b\x5b\x33\x7e' 正確 03/05 08:37
subset: 不過我自己在ubuntu下測試 bs='\x08' 03/05 08:38