现有一些文件 需要进行过滤处理如下
处理之后如下:
代码如下:
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import re
import sys
def Filternumber(f):
n = []
v = []
for i in open(f,'r'):
try:
if re.match('^[0-9]',i):
n.append(i.rstrip())
if re.search('(.*)[a-z]',i):
v.append(i)
except Exception as e :
print e
return n,v
def Values():
c = open('2.txt','w')
a,b = Filternumber(f)
for i in range(len(a)):
c.writelines((a[i],b[i]))
c.close()
f = sys.argv[1]
Values()