random 随机生成字符串

# import random
# for x in range(10):
# i = 0
# l = []
# while i < 10:
# ret = chr(random.randint(33, 126))
# if ret not in ['/','\','@','I','l','o','O']:
# i+=1
# l.append(ret)
# print(''.join(l))

import random
import string
for x in range(10):
str_source = string.ascii_letters + string.digits + string.punctuation
str_list = random.sample(str_source,7)
if str_list not in ['/','\','@','I','l','o','O']:
str_final = ''.join(str_list)
print(str_final)
原文地址:https://www.cnblogs.com/tengfei520/p/8794242.html