Note: if there are files in the directory, deleting the directory directly will fail, and prompt 550 remove directory operation failed
You must delete all the files in the directory before deleting the directory
FTP command line:
FTP delete directory command:
rmdir Catalog Name
FTP delete file command:
delete File Name
operation in Python:
Delete directory command:
ftp.rmd(Catalog Name)
Delete file command:
ftp.delete(File Name)
An example of deleting a directory in python3 is as follows:
from ftplib import FTP
ftp = FTP(host=xx, user=xx, passwd=xx)
ftp.cwd(dirname)
for i in ftp.nlst():
print(i)
ftp.delete(i)
ftp.cwd("..")
ftp.dir()
ftp.rmd(dirname)
Note: because there are only files in my directory, there is no directory, so you can write like above. If there is a directory in your directory, you need to delete it recursively
Similar Posts:
- [Solved] passwd: Authentication token manipulation error
- C# call Python error no module named OS [How to Solve]
- How to read and write multiple files in Python?
- How to Solve Python SyntaxError: EOL while scanning string literal
- How to Solve MySQL-python Install Error:Python version 2.7 required, which was not found in the registry
- Differences of urllib, urllib2, httplib and httplib2 libraries in Python
- Python: How to Batch Read the Form Information in Word and output them to Excel file
- CentOS Yum download package error: invalid space in download directory
- ORA-01940: cannot drop a user that is currently connected [How to Solve]
- Error reporting using Yum: Yum except keyboardinterrupt, e