python 实现文件传输脚本
直接上传代码
# coding: utf-8 import paramiko import os import time def file_transfer(): start_time = time.time() host = '' port = 22 username = '' password = '' t = paramiko.Transport(host,port) t.connect(username=username, password=password) sftp = paramiko.SFTPClient.from_transport(t) #发送文件夹的位置 bendiPath = "/home/data/bak/2020.zip" #接收文件夹的位置 servicePath = '/home/xuchunlin/' print bendiPath print servicePath print time.time() - start_time #C_M_202101_392_HS.zip 是文件的名字 sftp.put(bendiPath,os.path.join(servicePath, "C_M_202101_392_HS.zip")) t.close() print time.time() - start_time if __name__ == '__main__': file_transfer()
如果觉得对您有帮助,麻烦您点一下推荐,谢谢!
好记忆不如烂笔头
好记忆不如烂笔头