使用 Paramiko 进行目录传输 [英] Directory transfers with Paramiko

查看:76
本文介绍了使用 Paramiko 进行目录传输的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用Paramiko 传输完整目录?我正在尝试使用:

How do you use Paramiko to transfer complete directories? I'm trying to use:

sftp.put("/Folder1","/Folder2")

这是给我这个错误 -

错误:[Errno 21] 是一个目录

Error : [Errno 21] Is a directory

推荐答案

您需要像在本地使用 python 一样执行此操作(如果您不使用 Shutil).

You'll need to do this just like you would locally with python (if you weren't using shutils).

os.walk()sftp.mkdir()sftp.put() 结合起来.您可能还想使用 os.path.islink() 检查每个文件和目录,具体取决于您是否要解析符号链接.

Combine os.walk(), with sftp.mkdir() and sftp.put(). You may also want to check each file and directory with os.path.islink() depending on whether you want to resolve symlinks or not.

这篇关于使用 Paramiko 进行目录传输的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆