Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 ftputil库和JPG文件的问题_Python 2.7_Ftp_Ftputil - Fatal编程技术网

Python 2.7 ftputil库和JPG文件的问题

Python 2.7 ftputil库和JPG文件的问题,python-2.7,ftp,ftputil,Python 2.7,Ftp,Ftputil,我的代码如下所示 for root, dirs, files in ftp_host.walk(ftp_host.curdir, topdown=False): if ftp_host.path.isdir(root): for folder in ftp_host.path.normpath(root).split('/'): target_dir = os.path.join(target_dir, folder) if

我的代码如下所示

for root, dirs, files in ftp_host.walk(ftp_host.curdir, topdown=False):
    if ftp_host.path.isdir(root):
        for folder in ftp_host.path.normpath(root).split('/'):
            target_dir = os.path.join(target_dir, folder)
            if not os.path.exists(target_dir):
                os.mkdir(target_dir)

    for name in files:
        target_file = os.path.join(target_dir, name)
        # print name - I am able to see all files here including *.JPG  
        if ftp_host.path.isfile(name):
           # print name - there no any *.JPG  
           ftp_host.download(name, target_file)

    target_dir = curdir
当我尝试从目标FTP递归下载所有文件时,但我无法下载任何JPG


请告诉我哪里错了我的坏。。。我无法正确移动到特定目录。ftputils工作得很好