随笔分类 -  python

摘要:match()函数是在string的开始位置匹配,如果不匹配,则返回Nonesearch()会扫描整个string查找匹配;也就是说match()只有在0位置匹配成功的话才有返回,例如:print(re.match(‘super’, ‘superstition’).span()) 会返回(0, 5... 阅读全文
posted @ 2014-08-12 14:46 sun sun 阅读(2659) 评论(0) 推荐(0)
摘要:1. python中使用shell命令有多种方法,我自己觉得比较好用的是用commands模块:import commandsa,b = commands.getstatusoutput("ls -Al")a是退出状态(int类型), b是shell 命令的输出结果python -> shell:1... 阅读全文
posted @ 2014-08-12 11:41 sun sun 阅读(1983) 评论(0) 推荐(0)