Python生成随机字符串(可读字符串)

我们要的是一个可读的字符串,因此os.urandom这种是不靠谱的。

[python]
#生成一个Population
pop = [chr(i) for i in xrange(33, 126 + 1)]

#sample随机选取,然后再Join
print "".join(random.sample(pop, 64))
[/python]

Leave a Reply

Your email address will not be published. Required fields are marked *