#Python 3.6 (32-bit)
import random,string
count = input('请输入你要产生多少条密码:').strip()
all_passwds = []
for i in range(int(count)):
num = random.sample(string.digits,1) #随机取1位数字
lower = random.sample(string.ascii_lowercase,1) #随机取1位小写字母
upper = random.sample(string.ascii_uppercase,1) #随机取1位大写字母
other = random.sample(string.ascii_letters+string.digits,5) #随机取5位
res = num+lower+upper+other #产生的8位密码
res = ''.join(res)+'\n'
print('result:',res)
if res not in all_passwds: #判断是否重复
all_passwds.append(res)
with open('passwds.txt','a+') as fw:
fw.seek(0)
fw.writelines(all_passwds)