我正在尝试使用 Python 3.3 将一个简单文件从本地主机 (Windows) 上传到远程机器 (UNIX)
这是代码:
import os
import Crypto
import paramiko
import pysftp
localpath = "C:\\py.txt"
remotepath = "/tmp/py.txt"
s = pysftp.Connection(host='10.1.1.1', username='user', password='pass')
s.put(localpath, remotepath)
返回的错误是:
Traceback (most recent call last):
File "<pyshell#10>", line 1, in <module>
s.put(localpath, remotepath)
File "C:\Python33\lib\site-packages\pysftp.py", line 349, in put
confirm=confirm)
File "C:\Python33\lib\site-packages\paramiko-1.14.0- py3.3.egg\paramiko\sftp_client.py", line 585, in put
file_size = os.stat(localpath).st_size
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'C://py.txt'
我为 localpath 尝试了不同的前缀,例如 'C:\py.txt' 但我得到了相同的结果。
提前致谢