FTP 経由でアドレスに接続し、すべてのコンテンツを削除したい。現在、私はこのコードを使用しています:
from ftplib import FTP
import shutil
import os
ftp = FTP('xxx.xxx.xxx.xxx')
ftp.login("admin", "admin")
for ftpfile in ftp.nlst():
if os.path.isdir(ftpfile)== True:
shutil.rmtree(ftpfile)
else:
os.remove(ftpfile)
私の問題は、彼が最初のファイルを削除しようとすると、常にこのエラーが発生することです。
os.remove(ftpfile)
WindowsError: [Error 2] The system cannot find the file specified: somefile.sys
誰にも理由がありますか?