Generate password in python

前端 未结 9 2005
既然无缘
既然无缘 2020-12-12 21:51

I\'dl like to generate some alphanumeric passwords in python. Some possible ways are:

import string
from random import sample, choice
chars = string.letters          


        
9条回答
  •  醉酒成梦
    2020-12-12 22:32

    Here in the line 9 of above coding:

    return (choice(options) for _ in xrange(length))
    

    Actually the xrange is not defined, so the correct coding for this is:

    return (choice(options) for _ in range(length))
    

    Same in 76 line too.

提交回复
热议问题