小練習 - 密碼產生器

import random
#n = number of password, long = long of password
def made_a_password(n,long):
    symbol='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
    password = {}
    for i in range(n):
        lst = list()
        #init the list, make it keep empty
        for c in range(long):
            lst.append(symbol[random.randint(0, len(symbol)-1)])
        #join the list to a string,and add to the dict
        password[i] = ''.join(lst)
    return password

def main():
    print(made_a_password(2, 15))

if __name__ == '__main__':
    main()

0 意見:

張貼留言