我刚刚开始使用Python的pysftp,我很困惑如何调用它的walktree
函数。pysftp.Connection.walktree()参数的解释
我发现了一些代码(在http://pydoc.net/Python/pysftp/0.2.8/pysftp/找到),帮助我更好地了解形成我的参数应该采取
def walktree(self, remotepath, fcallback, dcallback, ucallback, recurse=True):
'''recursively descend, depth first, the directory tree rooted at
remotepath, calling discreet callback functions for each regular file,
directory and unknown file type.
:param str remotepath:
root of remote directory to descend, use '.' to start at
:attr:`.pwd`
:param callable fcallback:
callback function to invoke for a regular file.
(form: ``func(str)``)
:param callable dcallback:
callback function to invoke for a directory. (form: ``func(str)``)
:param callable ucallback:
callback function to invoke for an unknown file type.
(form: ``func(str)``)
:param bool recurse: *Default: True* - should it recurse
:returns: None
但我仍对到底什么是“回调函数意味着援引定期困惑。文件,目录,以及未知的文件类型
我也通过官方文档看了:https://media.readthedocs.org/pdf/pysftp/latest/pysftp.pdf
但所有它告诉我有关walktree()
的功能是:
是可以递归(默认)走远程 目录结构和用于 调用用户提供的回调函数在每次遇到文件,目录或未知实体的有效方法。它用于 pysftp的方法,可用于您自己的出价很大的作用 。每个回调都提供了 实体的路径名。 (形式:
func(str)
)
我觉得没有给我很多关于如何正确调用它的信息。
如果有人可以提供正确调用此函数的示例,并解释为什么您要传递所选参数,将不胜感激!