#Imports
import string
import random
import time
digits = string.digits
letters = string.ascii_letters
punctuation =("!\"\<>@#£$%^&*")
PasswordCode = letters+punctuation+digits
PassLenInput = input("How long should the password be?")
PassLenInput = int(PassLenInput)
for i in range(PassLenInput):
print(random.choice(PasswordCode),end="")
我的輸出如下的Python 3.0 - 指定範圍內環路輸出變量
How long should the password be?4
GtRA
我想保存這個輸出到一個叫傳變量,然後該變量保存到一個文本文件
感謝
僅供參考,因爲它陰影蟒蛇,你不應該使用'pass'作爲變量名['pass'(HTTPS://docs.python .org/3/reference/simple_stmts.html#pass)語句 – DavidG