随笔分类 - Python
摘要:需求:快速进行ftp上传 ,下载,查询文件原来直接在shell下操作:需要【连接,输用户名,输密码,单文件操作,存在超时限制】太过于繁琐,容易操作失败脚本改进:一句命令,搞定多文件上传,下载,查询,列表等操作后期可以加入更强大的功能直接上脚本:[python] view plaincopyprint...
阅读全文
摘要:python本身自带一个FTP模块,可以轻松实现FTP的上传,下载等操作。下面来看看用法:from ftplib import FTPimport socket #用来设置超时时间FTP.connect(服务器地址,端口,超时时间) # 连接服务器FTP.login(用户名,用户密码) # 用户登录...
阅读全文
摘要:import osimport os.pathrootdir = “d:\data” # 指明被遍历的文件夹for parent,dirnames,filenames in os.walk(rootdir): #三个参数:分别...
阅读全文
摘要:1: os.listdir(path) //path为目录 功能相当于在path目录下执行dir命令,返回为list类型 print os.listdir('..') 2: os.path.walk(path,visit,arg) path :是将要遍历的目录 visit :是一个函数指针,函数圆形...
阅读全文
摘要:文件是我们储存信息的地方,我们经常要对文件进行读、写、删除等的操作,在Python中,我们可用Python提供的函数和方法方便地操作文件。9.1.文件处理的函数和方法使用Open()函数可打开文件,语法格式如下:file_handler = open(filename,[,mode[,bufsize...
阅读全文
摘要:sudo apt-get install graphviz ghostscript postgresql-client python-dateutil python-feedparser python-gdata python-ldap python-libxslt1 python-lxml pyt...
阅读全文
摘要:pyPdf库 (http://pybrary.net/pyPdf/) ,操作起来相当直接易懂,把代码贴在这儿,做个记录。1frompyPdfimportPdfFileWriter,PdfFileReader23pdf=PdfFileReader(file('original.pdf','rb'))4...
阅读全文
摘要:Postgresql两表联合更新近日使用Postgresql感到有点不好用,一个联合更新非要这样写语法才对:update d_routetripset name=b.name , description=b.descriptionfrom d_scenery as bwhere foreignid=...
阅读全文
摘要:一直没有好好关注这个功能,昨天看了一下,数据库插入有瓶颈,今天研究了一下:主要有以下方案:1.使用copy从文件导入:copy table_001(a, b, "f", d, c, "e") from 'd:/data1.txt' (delimiter ','); 速度极快: 不带索引: 查询...
阅读全文