-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathguessnum.py
More file actions
27 lines (24 loc) · 885 Bytes
/
guessnum.py
File metadata and controls
27 lines (24 loc) · 885 Bytes
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
import random
import os
def numberguess(qq):
a = random.randint(0,9)
b = random.randint(0,9)
while a == b:
b = random.randint(0,9)
c = random.randint(0,9)
while a == c or b == c:
c = random.randint(0,9)
d = random.randint(0,9)
while a == d or b == d or c == d:
d = random.randint(0,9)
location = os.path.abspath(os.path.join(os.path.dirname(__file__), 'guessnum', str(qq) + '.txt'))
with open(file=location, mode='w', encoding="utf-8") as data:
data.write(str(a)+"\n")
data.write(str(b)+"\n")
data.write(str(c)+"\n")
data.write(str(d)+"\n")
data.write("8\n")
data.close()
def gameend(qq):
location = os.path.abspath(os.path.join(os.path.dirname(__file__), 'guessnum', str(qq) + '.txt'))
os.remove(location)