摘要: 前不久学了点python,昨天刚好要处理一个文件,于是拿来试试。 1)正则表达式的使用。#正则表达式的模块import re#正则表达式rePattern = '.*[0-9]{4}'pattern = re.compile(rePattern)#匹配if pattern.match(line): return Trueelse: return False 2)在函数中使用全局变量。def func(): global num 3)python默认print输出换行。如果需要输出时不换行,在最后加上逗号即可。print 'Hello World!', 4)字符串 阅读全文
posted @ 2012-10-05 10:21 coltfoal 阅读(2337) 评论(9) 推荐(2) 编辑