2016-04-04 38 views
0

我想在python中使用telnet庫從設備獲取信息。然而,我有一個錯誤,如上所列,當我嘗試運行我的代碼時被拋出。'str'對象不支持項目分配telnetlib

'海峽' 對象不支持項目分配

tn = telnetlib.Telnet(host) 
    tn.expect([r".*ogin:.*", r".*sername:.*"]) 
    tn.write(username+"\n") 
    tn.expect(r".*assword:.*") 
    tn.write(password+"\n") 
    tn.write("terminal length 0"+"\n") 
    tn.write("show " + configType + "-config"+"\n") 
    tn.write("exit"+"\n") 
    output = tn.read_all() 
+1

追溯哪裏? –

回答

1

在4號線你正在做

tn.expect(r".*assword:.*") 

telnet.expect只接受list

+0

所以我需要基本上把這個列表 – Johnathon64

+0

@ Johnathon64是的。 –

相關問題