下面的实现比较简单,大致看一眼就知道了。。
import random
list1 = [chr(i) for i in range(97, 122)] + [str(i) for i in range(10)]
list2 = [str(i) for i in range(10)]
list3 = [str(i) for i in range(10) if i != 0]
class New_params():
def new_udid(self):
str1 = ''.join(random.sample(list1,8))
str2 = ''.join(random.sample(list1,4))
str3 = ''.join(random.sample(list1,4))
str4 = ''.join(random.sample(list1,4))
str5 = ''.join(random.sample(list1,12))
list0 = [str1,str2,str3,str4,str5]
udid = '-'.join(list0)
return udid
def new_ip(self):
list_ip1 = [str(i) for i in range(110,118)]
list_ip2 = [str(i) for i in range(110,130)]
list_ip3 = [str(i) for i in range(201,255)]
list_ip = [random.choice(list_ip1),random.choice(list_ip2),random.choice(list_ip2),random.choice(list_ip3)]
ip_new = '.'.join(list_ip)
return ip_new
def new_accesskey(self):
str_access = random.sample(list1,32)
new_accessk = ''.join(str_access)
return new_accessk
def new_uid(self):
uid1 = random.sample(list3,8)
new_uid = ''.join(uid1)
return new_uid
# print(New_params().new_accesskey(),end='\n')
# print(list3)