Creating list from retrlines in Python

前端 未结 2 409
余生分开走
余生分开走 2020-12-10 17:54

How exactly would you create a list of the entries in an FTP directory?

This is my code so far:

import ftplib

files = []

my_ftp = ftplib.FTP(HOST)
         


        
2条回答
  •  时光说笑
    2020-12-10 18:43

    A little change to the callback argument and the following should work

    line = my_ftp.retrlines("NLST",files.append)
    

提交回复
热议问题