#coding: utf-8
__author__ = 'vanxkr.com'
p = './dic.txt'
import exrex, time
def dic_create(s):
c = exrex.count(s)
g = exrex.generate(s)
f = open(p, "w")
n = 0
s = time.time()
t = time.time()
a = 0
for i in g:
f.write(i+'\n')
n+=1
if 0 == n%1000000:
f.flush()
t = time.time()
a = n / (t - s)
print('%s/%s (%s): %s/%s [%s]' % (int(t-s), int((c - n)/a), int(a), n, c, i))
f.flush()
f.close()
print('Done', int(time.time() - s))
if '__main__' == __name__:
dic_create(r'[a-z]{1,3}[0-9]{1,3}')
python正则表达式生成字典
可以请我喝杯咖啡吗QAQ~
本文作者:vanxkr
本文链接:http://www.vanxkr.com/2021/4/regex-exrex
版权声明:本博客所有文章除特别声明外,均采用CC BY-NC-SA 3.0许可协议。转载请注明出处!
0 条评论