擅长:python、mysql、java
<p>我优化了导入并将密码写入了一个文件:</p>
<pre><code>from string import digits
from string import ascii_letters as letters
import random
punctuation =("!\"\<>@#£$%^&*")
PasswordCode = letters+punctuation+digits
PassLenInput = int(input("How long should the password be?"))
password = ''
for i in range(PassLenInput):
password += random.choice(PasswordCode)
with open('password_file.txt', 'w') as f:
f.write(password)
</code></pre>