sftp_upload.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:facerecognition 作者: guoxiaolu 项目源码 文件源码
def sftp_upload(host,port,username,password,local,remote):
    sf = paramiko.Transport((host,port))
    sf.connect(username = username,password = password)
    sftp = paramiko.SFTPClient.from_transport(sf)
    try:
        if os.path.isdir(local):#?????????????
            for f in os.listdir(local):#??????
                sftp.put(os.path.join(local+f),os.path.join(remote+f))#????????
        else:
            sftp.put(local,remote)#????
    except Exception,e:
        print('upload exception:',e)
    sf.close()

#if __name__ == '__main__':
    # host = '121.69.75.194'#??
    # port = 22 #??
    # username = 'wac' #???
    # password = '8112whz' #??
    # local = '/Users/ngxin/Documents/xin/face_recognition/my_faces/'
    # remote = '/home/wac/ngxin/ftp_upload/'
    # local = 'F:\\sftptest\\'#?????????????????windows?????window???????????
    # remote = '/opt/tianpy5/python/test/'#?????????????????linux????
    #sftp_upload(host,port,username,password,local,remote)#??
    #sftp_download(host,port,username,password,local,remote)#??
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号