您的位置:首页 > 编程语言 > Python开发

用python通过ftp将文件上传到服务器

2012-10-18 12:27 906 查看
#!/usr/bin/env python

#-*- coding: utf-8 -*-

from ftplib import FTP

import sys,getpass,os.path

host = '10.1.1.1'

username ='test'

password = 'test'

localfile ='E:\\ftp_test.txt'

remotepath ='/test/test/test'

print "HELLO"

f =FTP(host)

f.login(username,password)

print "Welcome:",f.getwelcome()

f.cwd(remotepath)

fd = open(localfile,'rb')

f.storbinary('STOR %s' % os.path.basename(localfile),fd)

fd.close()

f.quit()
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: