【发布时间】:2012-04-06 11:30:52
【问题描述】:
我想通过 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
有人知道为什么吗?
【问题讨论】: