-
Notifications
You must be signed in to change notification settings - Fork 63
/
test.py
49 lines (37 loc) · 1.06 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import random
import string
def generate_random_str():
"""
生成一个指定长度的随机字符串
"""
list = []
for i in range(500):
# res = (''.join(random.choice(string.ascii_lowercase) for _ in range(3))) + 'cloud.com'
res = 'music' + (''.join(random.choice(string.ascii_lowercase) for _ in range(2))) + '.com'
if res not in list:
list.append(res)
with open('test.txt', 'w') as f:
for temp in list:
f.write(temp + '\n')
def compare():
with open('test.txt', 'r') as f:
res = f.read()
list1 = res.split('\n')
# for temp in list1:
# if list1.count(temp) != 1:
# print(temp)
# print(list1.count('mks.com'))
with open('test2.txt', 'r') as f:
res = f.read()
list2 = res.split('\n')
print(list1)
print(list2)
result = []
for temp in list1:
if temp not in list2:
result.append(temp)
print(result)
print(len(result))
if __name__ == '__main__':
generate_random_str()
# compare()