# -*- coding: utf-8 -*- """ Created on Sun Jul 26 23:19:32 2015 @author: lijiong """ import re path = 'C:/Users/lijiong/Desktop/qq_number.txt' file_qq = open(path) for line in file_qq.readlines(): m = re.match(r'[1-9][0-9]{5,9}\@\q{2}\.\c\o\m',line) if m: # match successfully print m.group() terms = m.group().split('@') print terms[0]原文链接:https://www.f2er.com/regex/360124.html