python ! 点菜脚本 | 正则表达式 | 文件读取

import os
import re


normal_count = 0
add_count= 0
chili_count = 0

fh = open('luncher.log')     
for line in fh.readlines():
    time_flag1 = re.search('-',line)
    time_flag2 = re.search(':',line)
    if time_flag1 and time_flag2 !=None:
        continue
    
    rs = re.search('1$',line)
    if rs!=None:
        normal_count = normal_count+1
    rs = re.search('1\+$',line)
    if rs!=None:
        add_count = add_count+1
    rs = re.search('1[\x80-\xff]{2}',line)
    if rs!=None:

        chili_count = chili_count+1


print 'normal_count='+str(normal_count)
print 'add_count='+str(add_count)
print 'chili_count='+str(chili_count)

你可能感兴趣的:(正则表达式,python,脚本,import)