懒人的PYTHON

上传人:壹****1 文档编号:567305984 上传时间:2024-07-19 格式:PPT 页数:19 大小:200KB
返回 下载 相关 举报
懒人的PYTHON_第1页
第1页 / 共19页
懒人的PYTHON_第2页
第2页 / 共19页
懒人的PYTHON_第3页
第3页 / 共19页
懒人的PYTHON_第4页
第4页 / 共19页
懒人的PYTHON_第5页
第5页 / 共19页
点击查看更多>>
资源描述

《懒人的PYTHON》由会员分享,可在线阅读,更多相关《懒人的PYTHON(19页珍藏版)》请在金锄头文库上搜索。

1、懒人的PYTHON smallfish能少敲就少敲点键盘的敲击次数有限手指辛苦程度阅读难度指数能少敲就少敲点f=open(a.txt)whileTrue:line=f.readline()ifnotline:breakprintlinef.close()withopen(a.txt)asf:line=f.readline()printline能少敲就少敲点ifvar1!=0:passifvar2!=None:passiflen(list1)0:passifdict1.has_key(a):passifnotvar1:passifnotvar2:passIfaindict1:pass能少敲就少敲

2、点dict1=name:smallfish,age:20printname:+dict1name+,age:+str(dict1age)printname:%s,age:%d%(dict1name,dict1age)printname:%(name)s,age:%(age)d%dict1能少敲就少敲点str1=abcdeprintstr1:3-abcprintstr13:-deprintstr1:-2-abcprintstr1:-1-edcba能少敲就少敲点list1=11,22,33,11,44,22list2=foreinlist1:ifenotinlist2:list2.append(e

3、)list3=list(set(list1)能少敲就少敲点list1=11,22,33,11,44,22list2=foreinlist1:ife%2=0:list2.append(e)list3=eforeinlist1ife%2=0能不重复就不重复时间宝贵重复劳动干点别的.能不重复就不重复能不重复就不重复easy_installxxxpipinstallxxx-esvn/git/hg.pipfreeze-listallpackagepipuninstallxx-uninstall能不重复就不重复$pipinstallpssh$pssh-hhost-iuname-a120:52:45SUCC

4、ESS127.0.0.1.20:08:53UTC2011i686GNU/Linux$cathost127.0.0.1pscp/prsync能不重复就不重复$pipinstallfabric$fabuname.输出略fromfabric.apiimport*env.hosts=127.0.0.1defuname():run(uname-a)能不重复就不重复$pipinstallsupervisor$catsupervisord.confprogram:hellocommand=python/home/smallfish/hello.pyautorstart=truestdout_log能不重复就

5、不重复$cathello.pyimportweburls=(/(.*),hello)app=web.application(urls,globals()classhello:defGET(self,name):returnhello:+nameif_name_=_main_:app.run()smallfishdesktop:$sudosupervisorctlstatushellohelloRUNNINGpid1008,uptime0:02:32smallfishdesktop:$sudosupervisorctlstophellohello:stoppedsmallfishdesktop:

6、$sudosupervisorctlstarthellohello:started能不重复就不重复能不重复就不重复db=MySQLdb.connect(.)cur=db.cursor()cur.execute(.)rs=cur.fetchall()printrsdb.close()$pipinstallweb.pyImportwebdb=web.database(dsn=mysql,)rs=db.select(table1)forrinrs:printr能不重复就不重复rs=db.select(“table2”,where=”id=1”,order=”idDESC”)rs=db.select(“xx”,limit=10,offset=20)db.update(“xx”,where=”id=10”,name=”aa”,xx=”dd”)db.delete(“xx”,where=”id=10”)rs=db.query(“selectxxfromxxxgroupbyddorderbyxx”)Over.THX!

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 建筑/环境 > 施工组织

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号