随笔分类 -  python

摘要:遍历存元组的列表进行操作一堆xy坐标,找出x,y的左上角与右下角[python] view plaincopyprint?max_t=reduce(lambdax,y:(max(x[0],y[0]),max(x[1],y[1])),l)p;min_t=reduce(lambdax,y:(min(x[0],y[0]),min(x[1],y[1])),l)用zipfile写压缩包[python] view plaincopyprint?f=zipfile.ZipFile("testzip.zip","w",zipfile.ZIP_DEFLATED)f.wri 阅读全文
posted @ 2012-11-25 21:50 godjob 阅读(296) 评论(0) 推荐(0)
摘要:python中对文件、文件夹的操作需要涉及到os模块和shutil模块。创建文件:1) os.mknod("test.txt") 创建空文件2)open("test.txt",w)直接打开一个文件,如果文件不存在则创建文件创建目录:os.mkdir("file")创建目录复制文件:shutil.copyfile("oldfile","newfile")oldfile和newfile都只能是文件shutil.copy("oldfile","newfile") 阅读全文
posted @ 2012-11-25 00:16 godjob 阅读(334) 评论(0) 推荐(0)
摘要:很有趣的一个网站,看看你能闯多少关http://www.pythonchallenge.com/pc/def/0.html答案:http://wiki.pythonchallenge.com/index.php?title=Main_Page 阅读全文
posted @ 2012-10-11 22:30 godjob 阅读(234) 评论(0) 推荐(0)
摘要:f you're creating a search engine you'll need a way to collect documents. In this excerpt from Tony Segaran's Programming Collective Intelligence the author shows you how to set up a simple web crawler using existing tools.I'll assume for now that you don't have a big collection 阅读全文
posted @ 2012-09-24 21:45 godjob 阅读(599) 评论(0) 推荐(0)