-
Notifications
You must be signed in to change notification settings - Fork 0
/
製作座號JSON.py
78 lines (67 loc) · 1.98 KB
/
製作座號JSON.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import json
def make(TotalStudentNum):
FirstLayerBoxContents = [
{
"type": "text",
"text": "0.註冊開始!!",
"size": "xl",
"weight": "bold"
},
{
"type": "text",
"text": "你是誰?點座號跟我說!!",
"size": "md"
}
]
count = 0
SecondLayerBoxContent = []
for i in range(1,TotalStudentNum+1):
SecondLayerBoxContent.append({
"type": "button",
"action": {
"type": "postback",
"label": "%i"%i,
"data": "start&num&%i"%i
},
"margin": "none",
"height": "sm"
})
count = count+1
if count == 5:
FirstLayerBoxContents.append( {
"type": "box",
"layout": "horizontal",
"contents": SecondLayerBoxContent
})
count = 0
SecondLayerBoxContent = []
if i == TotalStudentNum:
SecondLayerBoxContent.append({
"type": "button",
"action": {
"type": "postback",
"label": "師",#老師字太多了
"data": "start&num&師"
},
"margin": "none",
"height": "sm"
})
FirstLayerBoxContents.append( {
"type": "box",
"layout": "horizontal",
"contents": SecondLayerBoxContent
})
data = {
"type": "bubble",
"body": {
"type": "box",
"layout": "vertical",
"contents": FirstLayerBoxContents,
"spacing": "xs",
"margin": "none"
}
}
import os
os.system("echo fin 座號選擇.json")
with open('座號選擇.json', 'w', encoding='utf-8') as f:
json.dump(data, f)