本着xkcd漫画的精神......
>>> import random
>>> def password_gen():
... with open('/usr/share/dict/words') as f:
... words = [w.strip().lower() for w in f if w.strip().isalpha()]
... while True:
... yield ' '.join(random.sample(words, 4))
...
>>> g = password_gen()
>>> next(g)
'mansion yodelling sumner coordination'
>>> next(g)
'proving velvetiest upload muggers'
>>> next(g)
'southey unfortunately longshoremen settings'
>>> next(g)
'inundated mules coevals vicious'
Run Code Online (Sandbox Code Playgroud)