-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
64 lines (48 loc) · 1.43 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import csv
import json
import random, string
import qrcode
'''
fd = open('participants.csv', encoding="utf8")
reader = csv.DictReader(fd)
participants = {}
participants["users"] = list(reader)
print(participants["users"][0]["Full Name"])
'''
def randomword(length):
letters = string.ascii_lowercase
return ''.join(random.choice(letters) for i in range(length))
def qrcodes():
for i in range(217,230):
# Data to be encoded
data = 'https://catwork.azurewebsites.net/?uid=' + str(i)
# Encoding data using make() function
img = qrcode.make(data)
# Saving as an image file
img.save('uid_'+str(i)+'.png')
myusers = {}
myusers["users"]= []
myusers["links"]= [(0,1)]
'''
fd = open('participants.csv', encoding="utf8")
reader = csv.DictReader(fd)
participants["users"] = list(reader)
'''
for u in range (50):
user ={}
#user["name"] = participants["users"][u]["Full Name"]
user["name"] = "cat #" + str(u)
user["id"] = randomword(4)
user["pw"] = randomword(3)
user["score"] = 0
myusers["users"].append(user)
for i in range(100):
#start = random.randint(0,len(myusers["users"])-1)
#end = random.randint(0,len(myusers["users"])-1)
start = random.randint(0,49)
end = random.randint(0,49)
myusers["links"].append([start, end])
myusers["users"][start]["score"] += 1
with open('dataNew.json', 'w') as f:
json.dump(myusers, f)
#print(myusers)