python实现关键词拼接

发布于 / 生活 / 0 条评论
python实现关键词拼接,速度超快,12秒拼接200万关键词

from itertools import product
import time


class Keyword_Stitching():

def key_work(self):
with open('1.txt', encoding='utf-8') as a,\
open('2.txt', encoding='utf-8') as b,\
open('3.txt', encoding='utf-8') as c,\
open('4.txt', encoding='utf-8') as d:
A = [a_.strip() for a_ in a]
B = [b_.strip() for b_ in b]
C = [c_.strip() for c_ in c]
D = [d_.strip() for d_ in d]

with open('key.txt', 'a', encoding='utf8') as f:
for K in product(A, B, C, D):
f.write(f"{K[0]}{K[1]}{K[2]}{K[3]}\n")
print(f"{K[0]}{K[1]}{K[2]}{K[3]}")


if __name__ == '__main__'
S = time.time()
key = Keyword_Stitching()
key.key_work()
print(f'时{time.time()-S}')
转载原创文章请注明,转载自: 哲玺要挺猛 » python实现关键词拼接
Not Comment Found