-
Notifications
You must be signed in to change notification settings - Fork 0
/
draw.py
115 lines (97 loc) · 2.34 KB
/
draw.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# encoding=utf-8
import random
import os
strMenu = """——————随机点名器——————
1.批量点名
2.不重复点名
3.重复点名
4.编辑名单
5.退出
——————你值得信赖——————"""
listName = []
def start():
while True:
print(strMenu)
x = int(input(":"))
if x == 1:
os.system("cls")
batchRoll()
os.system("cls")
continue
elif x == 2:
os.system("cls")
noRepeatRoll()
os.system("cls")
continue
elif x == 3:
os.system("cls")
RepeatRoll()
os.system("cls")
continue
elif x == 4:
os.system("cls")
editList()
os.system("cls")
continue
else:
break
def batchRoll():
if os.path.exists(r".\list.txt"):
fo = open("list.txt","r")
else:
open("list.txt","w")
return
listName = fo.read().splitlines()
counting = int(input("点名次数:"))
for i in range(counting):
if listName:
name = random.choice(listName)
print(name)
listName.remove(name)
input(":")
fo.close()
listName = []
def noRepeatRoll():
if os.path.exists(r".\list.txt"):
fo = open("list.txt","r")
else:
open("list.txt","w")
return
listName = fo.read().splitlines()
while True:
if listName:
name = random.choice(listName)
print(name)
listName.remove(name)
#连续点名
x = input(":")
if x == '0':
break
else:
continue
else:
break
fo.close()
listName = []
def RepeatRoll():
if os.path.exists(r".\list.txt"):
fo = open("list.txt","r")
else:
open("list.txt","w")
return
listName = fo.read().splitlines()
if listName:
while True:
name = random.choice(listName)
print(name)
#连续点名
x = input(":")
if x == '0':
break
else:
continue
fo.close()
listName = []
def editList():
os.startfile("list.txt")
start()