我正在将代码迁移到python3.4.3。这段代码在python2.4.3中运行良好。但在这里它抛出了python3.4.3中的错误。
我应该使用与expect不同的东西吗?
以下是我的代码片段,其中包含错误:telconn=pexpect.spawn('telnet 10.24.12.83')
telconn.logfile = sys.stdout
login=telconn.expect([":","key to proceed.",">"])
if login==0:
telconn.send("user1" + "\r")
telconn.expect(":")
telconn.send("paswd1" + "\r\r\r\r\n\n\n")
login1=telconn.expect([">","key to proceed."])
if login1==0:
print("nothing")
elif login1==1:
telconn.expect("key to proceed.")
telconn.send ("\003")
telconn.expect(">")
if login==1:
telconn.send ("\003")
telconn.expect(">")
print("ctlc")
elif login==2:
telconn.send("\n\r")
telconn.expect(">")
我得到的错误是:
^{pr2}$