[問題] telnetlib write 相關問題已刪文

看板Python作者 (Be happy)時間5年前 (2020/02/25 14:16), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
最近剛碰Python幾個月,在學習telnetlib時候遇到一個問題。 Telnet 進去的畫面大部分是屬於數字輸入的部分,因此執行上是沒有問題的。 但在其中一個選項後,執行後會顯示一個詢問句(如下),必須直接在後面輸入"YES"或是"Enter"離開 Enter 'YES' to continue or <ENTER> to cancel : 但不管是第一種或是第二種,都無法進入到下一個句子,"Press <ENTER> to continue..." 下面是我寫的內容,希望版上有人能幫忙解惑,謝謝! (1)Enter 'YES' to continue or <ENTER> to cancel : YES Press <ENTER> to continue... print(tn.read_until(b"Enter 'YES' to continue or <ENTER> to cancel : \r\n").decode('ascii')) tn.write("YES".encode('ascii')+b"\r\n") print(tn.read_until(b"Press <ENTER> to continue...\r\n").decode('ascii')) tn.write(b"\r\n") (2)Enter 'YES' to continue or <ENTER> to cancel : Press <ENTER> to continue... print(tn.read_until(b"Enter 'YES' to continue or <ENTER> to cancel : \r\n").decode('ascii')) tn.write(b"\r\n") print(tn.read_until(b"Press <ENTER> to continue...\r\n").decode('ascii')) tn.write(b"\r\n") -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 125.227.150.181 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1582611360.A.2C4.html
文章代碼(AID): #1ULBkWB4 (Python)
文章代碼(AID): #1ULBkWB4 (Python)