# 方法一
import random
import string
totle_string = string.ascii_letters + string.digits
def auth_code(num):
res = ''.join(random.sample(totle_string, num))
return res
# 方法二
import random
import string
totle_string = string.ascii_letters + string.digits
def auth_code(num):
l = [i for i in totle_string]
random.shuffle(l)
return ''.join(l[0:num])