只需尝试列出只包含一个文件(/public_html/Data/ ['TestFile.txt']
)的远程FTP文件夹中的文件。
os.walk只是在无限循环中反复返回相同的文件名,直到我不手动中断。代码是:
import ftptool as f
a_host = f.FTPHost.connect("SomeFTPSite", user="User", password="Pass")
for (dirname, subdirs, files) in a_host.walk("/public_html/Data"):
print (dirname, files)
输出如下:
/public_html/Data/ ['TestFile.txt']
/public_html/Data/ ['TestFile.txt']
/public_html/Data/ ['TestFile.txt']
/public_html/Data/ ['TestFile.txt']
/public_html/Data/ ['TestFile.txt']
/public_html/Data/ ['TestFile.txt']
/public_html/Data/ ['TestFile.txt']
/public_html/Data/ ['TestFile.txt']
/public_html/Data/ ['TestFile.txt']
/public_html/Data/ ['TestFile.txt']
/public_html/Data/ ['TestFile.txt']
/public_html/Data/ ['TestFile.txt']
/public_html/Data/ ['TestFile.txt']
/public_html/Data/ ['TestFile.txt']
/public_html/Data/ ['TestFile.txt']
///此时手动中断///