You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
442 B
17 lines
442 B
5 years ago
|
import string
|
||
|
import random
|
||
|
|
||
|
s_list = string.ascii_letters + string.digits
|
||
|
|
||
|
words = ["".join([random.choice(s_list) for _ in range(random.randint(10, 100))]) for _ in range(100)]
|
||
|
with open('q2.txt', 'w') as f:
|
||
|
for w in words:
|
||
|
for w in words:
|
||
|
f.write(w)
|
||
|
f.write("\n")
|
||
|
with open('q2.txt', 'r') as f:
|
||
|
lines = f.readlines()
|
||
|
i = 0
|
||
|
for l in lines:
|
||
|
i += 1
|
||
|
print("{}个字符串".format(i))
|