#/usr//bin/env pytnon
#coding:utf-8
import re
‘‘‘
words = ‘hello word a@r3143# #### ##$dfabpple# apple##%#$ 3423421apple apple323423 432422324##apple@@# @@@@@ $$!!#!#‘
‘‘‘
#编译生成正则表达式对象
regexp = re.compile(r‘[a-zA-Z]{2,}‘)
#with open(‘./aa.txt‘) as f:
f = open(‘./aa.txt‘)
line = f.readlines()
print len(line)
j = 0
sum = 0
for i in range(len(line)):
j = len(regexp.findall(line[i]))
sum = sum + j
print sum本文出自 “linux与网络那些事” 博客,请务必保留此出处http://khaozi.blog.51cto.com/952782/1790792
原文地址:http://khaozi.blog.51cto.com/952782/1790792