def randstring(n=1, source=None):
"""Generate a random string of length 'n' from 'source'."""
if not source:
source = string.ascii_letters + string.digits
if n <= 0:
raise ValueError("Length of sequence must be greater than 0.", n)
return ''.join(random.choices(source, k=n))
评论列表
文章目录