# -*- coding: utf-8 -*-
#python 27
#xiaodeng
#python之模块ftplib(实现ftp上传下载代码) #需求:实现ftp上传下载代码(不含错误处理) from ftplib import FTP def ftpconnect():
ftp_server='ftp.python.org'
ftp=FTP()
ftp.set_debuglevel(2)#打开调式级别2
ftp.connect(ftp_server,21)
ftp.login('','')#username,password
return ftp #下载的实现
def downloadfile():
path='/home/static/test.jpeg'#查看需要下载的文件所在路径
ftp=ftpconnect()
print ftp.getwelcome()
bufsize=1024#设置缓冲块大小
localpath='D:\test2\dog.jpeg'#文件下载到哪里
fp=open(localpath,'wb')
#注意RETR后面的空格
ftp.retrbinary('RETR '+path,fp.write,bufsize)#接收服务器上的文件并写入本地
ftp.set_debuglevel(0)
fp.close()
ftp.quit() #上传的实现
def uploadfile():
path='/home/static/test.jpeg'
ftp=ftpconnect()
bufsize=1024
localpath='D:\test2\dog.jpeg'
fp=open(localpath,'rb')
#注意STOR后面的空格
ftp.storbinary('STOR '+path,fp,bufsize)#上传文件
fp.close()
ftp.quit() if __name__ == "__main__":
ftp = ftpconnect('','','')
downloadfile(ftp,'','')
uploadfile(ftp,'','')
ftp.quit() #来自:tianzhu123

python之模块ftplib(实现ftp上传下载代码)的更多相关文章

  1. python之实现ftp上传下载代码(含错误处理)

    # -*- coding: utf-8 -*- #python 27 #xiaodeng #python之实现ftp上传下载代码(含错误处理) #http://www.cnblogs.com/kait ...

  2. JAVA 实现FTP上传下载(sun.net.ftp.FtpClient)

    package com.why.ftp; import java.io.DataInputStream; import java.io.File; import java.io.FileInputSt ...

  3. windows系统下ftp上传下载和一些常用命令

    先假设一个ftp地址 用户名 密码 FTP Server: home4u.at.china.com User: yepanghuang Password: abc123 打开windows的开始菜单, ...

  4. windows下ftp上传下载和一些常用命令

    先假设一个ftp地址 用户名 密码 FTP Server: home4u.at.china.com User: yepanghuang Password: abc123 打开windows的开始菜单, ...

  5. FTP上传下载工具(FlashFXP) v5.5.0 中文版

    软件名称: FTP上传下载工具(FlashFXP) 软件语言: 简体中文 授权方式: 免费试用 运行环境: Win 32位/64位 软件大小: 7.4MB 图片预览: 软件简介: FlashFXP 是 ...

  6. 高可用的Spring FTP上传下载工具类(已解决上传过程常见问题)

    前言 最近在项目中需要和ftp服务器进行交互,在网上找了一下关于ftp上传下载的工具类,大致有两种. 第一种是单例模式的类. 第二种是另外定义一个Service,直接通过Service来实现ftp的上 ...

  7. C# -- FTP上传下载

    C# -- FTP上传下载 1. C#实现FTP下载 private static void TestFtpDownloadFile(string strFtpPath, string strFile ...

  8. Java.ftp上传下载

    1:jar的maven的引用: 1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="ht ...

  9. java客户端调用ftp上传下载文件

    1:java客户端上传,下载文件. package com.li.utils; import java.io.File; import java.io.FileInputStream; import ...

随机推荐

  1. 如何打开google,facebok等网站

    用记事本打开 C:\WINDOWS\System32\drivers\etc\hosts 文件,粘贴如下蓝色内容到文件里,然后输入 例如 https://www.google.com   https: ...

  2. JavaScript:Events

    ylbtech-JavaScript:Events 1.返回顶部 JavaScript 事件参考手册 事件通常与函数配合使用,这样就可以通过发生的事件来驱动函数执行. 事件句柄 HTML 4.0 的新 ...

  3. BERT的开源实现的使用

    参考这篇文章: 小数据福音!BERT在极小数据下带来显著提升的开源实现 https://mp.weixin.qq.com/s?__biz=MzIwMTc4ODE0Mw==&mid=224749 ...

  4. Java vs C++ (7)导入

    用法 import VS include Java   import java.util.regex.Pattern; package com.slim; (1)假设少了; 会warning: C++ ...

  5. js将滚动条滚动到指定位置的方法

    代码如下(主要是通过设置Location的hash属性): <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN& ...

  6. Search Insert Position leetcode java

    Given a sorted array and a target value, return the index if the target is found. If not, return the ...

  7. ML&DL视频教程资源

    作者:Bruce链接:https://www.zhihu.com/question/49909565/answer/345894856来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载 ...

  8. 如何给USB移动硬盘格式化分区

    硬盘盒装好后,插在电脑USB接口上,电脑正常识别到移动硬盘后,但因为全新硬盘没有分区,在"我的电脑"里是看不到盘符的.下面以40G移动硬盘分区讲一下硬盘如何分区.1.操作系统最好是 ...

  9. idea 提交代码时提示 please tell me who you are .......

  10. android中Fragment的使用

    android中的Fragment跟网页中的iframe很像,用于在界面上嵌入局部动态内容,我的描述可能不准确,只是我的理解吧 创建Fragment很简单,在Android Studio中是这么创建的 ...