0
我嘗試關注instructions of the scpclient。Python /關閉未定義
我寫了下面的代碼:
import paramiko
client = paramiko.SSHClient()
client.load_system_host_keys()
client.set_missing_host_key_policy(paramiko.WarningPolicy())
client.connect("my_ip", username="root", password="password")
stdin, stdout, stderr = client.exec_command('display version')
with closing(Write(client.get_transport(), '.')) as scp:
scp.send_file("/tmp/myfile", remote_path="/tmp")
client.close()
但我得到了以下錯誤:
Traceback (most recent call last):
File "ssh.py", line 11, in <module>
with closing(Write(client.get_transport(), '.')) as scp:
NameError: name 'closing' is not defined
什麼能是什麼原因?
您還沒有定義'closing'。 – pacholik
您認爲'closing'的定義在哪裏?它不是一個內置函數的python,所以我認爲它實際上是' .closing' - 其中是一些模塊 –