This paper is finally updated at 1163 Days ago, , The information may have developed or changed .
take 0001 Question generated 200 Activation codes ( Or coupons ) Save to Redis In a non relational database .
import random
import string
import redis
re=redis.Redis()
print(re.get('mytest'))
def getKeys():
list=[]
str=string.ascii_uppercase
for i in range(200):
key = ""
for j in range(16):
key+=random.choice(str)
if (j+1)%4==0 and j !=15:
key+="-"
if not key in list:
list.append(key)
print(key)
else:
i-=1
return list
def main():
list=getKeys()
# for iteam in getKeys():
# re.lpush('py_03_list',iteam)
print("redis:")
print(re.lrange('py_03_list',0,200))
main()
Post Views: 331