循环不解压我的文件...代码不进入循环

Loop doesn't unrar my files... Code doesn't enter into the loop

大家早上好,

我的代码有问题。我将解释一下,我在 linux 实例上连接到本地 FTP 服务器。我想探索我所有的目录以解压缩我的文件“.rar”,但是当我启动我的脚本时,只有目录显示正在工作。

不知道为什么。

def showDirectories(ftp):

  output=' /var/www/folder/Output'
  ftp.cwd('/FolderFiles')
  ftp.retrlines('LIST')
  directories = ftp.nlst()

  if directories not in ['..', '.']:
    i=0
    while i < len(directories):
      folder = directories[i]+'/'
      i+=1
      for root, dirs, files in os.walk(folder, topdown=False):
        for name in files:
          rarFiles=os.path.join(root, name)
          print(rarFiles)
          unrar = "unrar x "+rarFiles+output
          print("unrar commande"+str(unrar))
          download= os.system(unrar)
          print(download)
        ftp.cwd('..')
      print("")

这里是结果:

[root@ip-10-0-2-52 folder]# python test.py
Connected! Welcome msg is "220 (vsFTPd 3.0.2)"
Connected !

drwxr-xr-x    2 0        0              90 Feb 11 14:42 DescriptiveData
drwxr-xr-x    2 0        0              75 Feb 11 14:42 Financials
drwxr-xr-x    2 0        0              87 Feb 11 14:42 OwnershipHisto

感谢您的帮助

感谢您的帮助,我终于找到了使我的脚本正常工作的解决方案。

这是我更新的

def downloadFile(path,target):

  for root, dirs, files in os.walk(path, topdown=False):
    for name in files:
      rarFiles=os.path.join(root, name)
      print(rarFiles)
      unrar = "unrar x "+rarFiles+target
      print("unrar commande"+str(unrar))
      download= os.system(unrar)
      print(download)

downloadFile('*****','*****')