在pysftp中指定文件模式 [英] Specify file pattern in pysftp get
问题描述
我们可以这样编写一个简单的get
:
We can write a simple get
like this:
import pysftp
hostname = "somehost"
user = "bob"
password = "123456"
filename = 'somefile.txt'
with pysftp.Connection(hostname, username=user, private_key='/home/private_key_file') as sftp:
sftp.get(filename)
但是,我想在文件名中指定一个模式,例如:'*.txt'
However, I want to specify a pattern in the filename, something like: '*.txt'
关于如何使用pysftp
进行此操作的任何想法?
Any idea on how to do this using pysftp
?
推荐答案
没有功能可以在pysftp中下载与文件掩码匹配的文件.
There's no function to download files matching a file mask in pysftp.
您必须:
For an inspiration, see how get_d
or get_r
are implemented.
有关琐碎的实现,请参见列出使用Paramiko在Python中匹配通配符的SFTP服务器上的文件.有关递归示例,请参见来自Linux的Python pysftp get_r在Linux上可以正常运行,但在Windows上则无法运行.
For a trivial implementation, see List files on SFTP server matching wildcard in Python using Paramiko. For a recursive example, see Python pysftp get_r from Linux works fine on Linux but not on Windows.
这篇关于在pysftp中指定文件模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!