How do I parse a listing of files to get just the filenames in Python?

前端 未结 7 1544
一向
一向 2021-02-10 23:50

So lets say I\'m using Python\'s ftplib to retrieve a list of log files from an FTP server. How would I parse that list of files to get just the file names (the last column) ins

7条回答
  •  梦毁少年i
    2021-02-11 00:36

    Using retrlines() probably isn't the best idea there, since it just prints to the console and so you'd have to do tricky things to even get at that output. A likely better bet would be to use the nlst() method, which returns exactly what you want: a list of the file names.

提交回复
热议问题