我刚刚从https://github.com/sergeyzelyukin/cisco-telnet安装了“ ciscotelnet.py”
当我尝试运行时:
import ciscotelnet
with ciscotelnet.CiscoTelnet("10.3.99.34", verbose = False) as cisco:
if cisco.login(final_mode=CiscoTelnet.MODE_ENABLE, user="admin", user_pass="x", enable_pass="x"):
cisco.cmd("sh interface status")
然后我得到了错误:
Traceback (most recent call last):
File "C:\python\cisco.py", line 4, in <module>
if cisco.login(final_mode=CiscoTelnet.MODE_ENABLE, user="admin", user_pass="atmadmin", enable_pass="cisco"):
NameError: name 'CiscoTelnet' is not defined
我做错了什么?我是Python的新手。
答案 0 :(得分:0)
将第一个导入替换为:
from ciscotelnet import CiscoTelnet
因此您可以始终使用CiscoTelnet而不是ciscotelnet.CiscoTelnet。这意味着您应该替换
with ciscotelnet.CiscoTelnet....
对于
with CiscoTelnet(
答案 1 :(得分:0)
谢谢,现在我出错了
"Traceback (most recent call last): File "C:\python\cisco.py", line 6, in <module> if cisco.login(final_mode=CiscoTelnet.MODE_ENABLE, user="admin", user_pass="x", enable_pass="x"): AttributeError: type object 'CiscoTelnet' has no attribute 'MODE_ENABLE'"
我打开了ciscotelnet.py文件,看到了这种模式!