我是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()
要移动文件,请使用^{} 。在
假设
filepathSource
和filepathDestination
都是远程文件,那么可以:相关问题 更多 >
编程相关推荐