文件名称:正则表达式学习
文件大小:564B
文件格式:RAR
更新时间:2020-12-04 16:44:44
正则表达式; 入门; python; re;
正则表达式; 入门; python # -*- coding: utf-8 -*- """ Created on Wed Nov 08 11:23:32 2017 @author: Administrator """ import os import re os.chdir(r"d:\nlp_course") f = open("employee.txt") f_txt = f.read().decode("gbk") rule = r".*([0-9]{17}[0-9]|x|X).*" employee_id = re.findall(rule,f_txt) print employee_id s="011abc" a=re.search("([0-9]{2}\w)",s) print a
【文件预览】:
re_employee.py
employee.txt