python ! 点菜脚本 | 正则表达式 | 文件读取
2011-08-14 21:13
393 查看
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)
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从文件中读取字符串,用正则表达式匹配中文字符的问题
- python中使用文件的读取编码问题和简单正则使用(一)
- perl正则表达式,文件读取常用方法
- Hadoop 和 spark 读取多个文件通配符规则(正则表达式)joe
- python中使用文件的读取编码问题和简单正则使用(二)
- Python 正则表达式从CSV文件提取特定列
- 使用正则表达式读取简单的xml文件
- Hadoop 和 spark 读取多个文件通配符规则(正则表达式)joe
- 读取javascript脚本的正则表达式
- 【Python基础】05、Python文件对象与正则表达式
- Python 正则表达式改变csv文件的分隔符
- python基础学习笔记(三) 文件、time和正则表达式
- python读取csv文件并把文件放入一个list中脚本实例
- Hadoop 和 spark 读取多个文件通配符规则(正则表达式)joe
- [Python]_[使用正则表达式提取迅雷界面配置文件XLUE的图片]
- Hadoop 和 spark 读取多个文件通配符规则(正则表达式)joe
- Python-老男孩-01_基础_文件IO_函数_yield_三元_常用内置函数_反射_random_md5_序列化_正则表达式_time
- 利用正则表达式读取txt文件中的邮箱,电话号码,url地址,手机号,将数据一行一个保存到一个新的文件中去
- [Python]_[使用正则表达式提取迅雷界面配置文件XLUE的图片]
- ios常用的读取文件路径操作以及正则表达式