随机字符串生成

import random # 数字库
import string  # 字符串库
code=string.digits+string.ascii_letters
print(code)

# 生成字符串
def getCode():
	# sample 取出样本
	return ''.join(random.sample(code,4))
print(getCode())
def key(group):
	return "-".join([getCode() for i in range(group)])
print((key(5)))

  

posted @ 2020-12-28 19:32  睁yan-ii  阅读(81)  评论(0编辑  收藏  举报