12 2009 档案
摘要: 一 python压缩解压libszlib:infozip免费的压缩lib。bzip2:读写bz压缩文件,与bzip2和bunzip2压缩程序兼容。gzip: 读写gz压缩文件,与GNU压缩程序gzip和gunzip兼容。zipfile:读写zip压缩文件,与zip,unzip,pkzip,pkunzip,winzip等程序兼容。tar:读写tar包文件。7z等程序可以大包和解包tar。二 zip压缩解压实例Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/阅读全文
摘要: 一 常用函数os模块os.sep 表示默认的文件路径分隔符,windows为\, linux为/os.walk(spath): 用来遍历目录下的文件和子目录os.listdir(dirname):列出dirname下的目录和文件os.mkdir() : 创建目录os.makedirs(): 创建目录,包含中间级目录os.remove():删除文件,不能是目录os.rmdir():删除空目录os.removedirs(path):删除目录及其子目录os.rename(src, dst) :修改文件名os.renames(old, new) :修改文件或目录名,包含中间级os.chdir(&quo阅读全文
摘要: 一 Open 函数 open(path [,mode [,buffersize]]) 1)path文件的路径。2)mode文件的读写模式。r读打开存在的文件,w写打开文件,如果文件存在以前的内容被覆盖,如果文件不存在则创建之, a打开存在的文件添加新内容,r+读写打开文件,以前的被人被保留,w+读写打开文件,以前的内容被覆盖, a+读写打开文件,以前的被人被保留, b与rwa之一配合使用,表示以二进制打开,u与rwa之一配合使用,Applies the "universal" newline translator to the file as it is opened.3)阅读全文
摘要: 主站:主页:http://python.org/下载:http://python.org/download/文档:http://python.org/doc/books:ActivePython31.chm Python in a Nutshell, 2nd Edition.chmPython Phrasebook: Essential Code and Commands GUI: http://www.wxpython.org/ python封装的wxWidgets开发库http://www.pygtk.org/ python封装的GTK+的开发库http://wiki.python.org阅读全文
摘要: 一 string与引号Python中的字符串可以使用四种引号来表示,‘(单引号),“(双引号),’‘'(三单引号),"""(三双引号)。 且他们均有相同的意思,需成对出现,单双引号可以相互嵌套。没有任何区别。 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->>>>print('hesaid"good",yousaid"great",andi阅读全文
摘要: 一 对象相等性比较python 对于string,tuple,list,dict,只要内容相等则为相等,但是对于自定义对象则不是。Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->print('---------------str-------------------------')mystr=""mystr2="test"mystr3='test'ifmystr==&qu阅读全文
摘要: 转自:http://blog.chinaunix.net/u3/107531/showart_2117609.html文件:datafileSteve Blenheim:238-923-7366:95 Latham Lane, Easton, PA 83755:11/12/56:20300Betty Boop:245-836-8357:635 Cutesy Lane, Hollywood, CA ...阅读全文
摘要: ① 在Python中通过HTTP下载东西是非常简单的; 实际上,只需要一行代码。urllib.request模块有一个方便的函数urlopen() ,它接受你所要获取的页面地址,然后返回一个类文件对象,您只要调用它的read()方法就可以获得网页的全部内容。没有比这更简单的了。 ② urlopen().read()方法总是返回bytes对象,而不是字符串。记住字节仅仅是字节,字符只是一种抽象。 HTTP 服务器不关心抽象的东西。如果你请求一个资源,你得到字节。 如果你需要一个字符串,你需要确定字符编码,并显式的将其转化成字符串。代码如下:Code highlighting produced b阅读全文
摘要: Controlling VM by Script1 VMRunVMRun is a command line tool which is delivered with VM workstation or VM server. the tool have many sub commands to control VM, such as starting and stopping VM, creati...阅读全文