【发布时间】:2016-10-29 01:37:01
【问题描述】:
我正在尝试将 FTP 位置中的一些 XML 文件移动到同一 FTP 中的另一个位置。我尝试了以下代码,但它不起作用。
def ftpPush(filepathSource, filename, filepathDestination):
try:
ftp = FTP(ip, username, password)
ftp.cwd(filepathDestination)
ftp.storlines("STOR "+filename, open(filepathSource, 'r'))
ftp.quit()
for fileName in os.listdir(path):
if fileName.endswith(".xml"):
ftpPush(filepathSource, filename, filepathDestination)
except Exception, e:
print str(e)
finally:
ftp.close()
【问题讨论】: