<p>我已经包括了整个问题陈述和使用的代码。当我尝试两种可选的char_列表结构时,这两种结构都被包含并注释掉了;问题在这两种情况下都存在。你知道吗</p>
<p>为什么<code>' '.join()</code>不清理空间?你知道吗</p>
<pre><code>'''Write a password generator in Python. Be creative with how you generate passwords - strong passwords have a mix of lowercase letters, uppercase letters, numbers, and symbols. The passwords should be random, generating a new password every time the user asks for a new password. Include your run-time code in a main method.'''
import random
def password_generator():
#char_str = '1234567890abcdefgh!@#$%(^)%($('
#char_str = ['a', 'b', 'c', 'd', '1', '2', '3', '4']
password = []
length = int(input("How long should the password be?"))
while len(password) < length:
password.append(char_str[random.randint(0, len(char_str) - 1)])
return(' '.join(password))
print(password_generator())
</code></pre>
<p>输出示例:<code>% ) 0 4 d c f b % 7</code></p>