(对不起我的英文)
伙计们,我的Python课程运行一次
import csv, random
class myPassword:
azlower = "abcdefghijklmnopqrstuvwxyz"
azupper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
vowel = "aeiouAEIOU"
simbol = "!@#$%*"
passw = random.sample(range(9), 2)
passw = ''.join(map(str, passw))
passw += random.choice(simbol)
passw += random.choice(azupper)
passw += random.choice(vowel)
passw += random.choice(azlower)
passw += random.choice(simbol)
passr = random.sample(range(9), 3)
passw += ''.join(map(str, passr))
for i in range (0,2):
print (myPassword.passw)
此代码在每个for
中运行相同的密码。
如何再次上课?
TKX!
答案 0 :(得分:3)
在这里使用课程不是必须的。您想使用方法:
def myPassword():
azlower = "abcdefghijklmnopqrstuvwxyz"
azupper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
vowel = "aeiouAEIOU"
simbol = "!@#$%*"
passw = random.sample(range(9), 2)
passw = ''.join(map(str, passw))
passw += random.choice(simbol)
passw += random.choice(azupper)
passw += random.choice(vowel)
passw += random.choice(azlower)
passw += random.choice(simbol)
passr = random.sample(range(9), 3)
passw += ''.join(map(str, passr))
return passw
for i in range (2):
print (myPassword())