Random strings in Python 2.6 (Is this OK?)

前端 未结 5 1695
独厮守ぢ
独厮守ぢ 2020-12-12 12:54

I\'ve been trying to find a more pythonic way of generating random string in python that can scale as well. Typically, I see something similar to

\'\'.join(r         


        
5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-12 13:35

    Taken from the 1023290 bug report at Python.org:

    junk_len = 1024
    junk =  (("%%0%dX" % junk_len) % random.getrandbits(junk_len *
    8)).decode("hex")
    

    Also, see the issues 923643 and 1023290

提交回复
热议问题