我是Python的新手.我试图将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()
Run Code Online (Sandbox Code Playgroud)