#/usr//bin/env pytnon #coding:utf-8 import re ‘‘‘ words = ‘hello word [email protected]# #### ##$dfabpple# apple##%#$ 3423421apple apple323423 432422324##[email protected]@# @@@@@ $$!!#!#‘ ‘‘‘ #编译生成正则表达式对象 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
时间: 2024-10-15 05:32:20