-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplace.py
More file actions
58 lines (46 loc) · 1.92 KB
/
place.py
File metadata and controls
58 lines (46 loc) · 1.92 KB
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
import os
import timecheck
def changeplace(qq,choose):
check = os.getcwd()
location = os.path.abspath(os.path.join(os.path.dirname(__file__), 'place', str(qq) + '.txt'))
if not os.path.exists(location):
with open(file=location, mode='w', encoding="utf-8") as data:
data.write("0\n")
data.close()
with open(file=location, mode='w', encoding="utf-8") as data:
data.write(choose + "\n")
if(choose=="0" or choose =="2-0"):
return 2
url = os.path.abspath(os.path.join(os.path.dirname(__file__), 'place', 'First_' + choose + '.txt'))
date = str(timecheck.times())
with open(file=url, mode='r', encoding="utf-8") as data:
lastdate = data.readline()
lastdate = lastdate.strip()
lasts = lastdate
xn = ['' for x in range(50)]
n = 0
while lasts != "-1" and date == lastdate:
lasts = data.readline()
lasts = lasts.strip()
if lasts == qq:
return 2 #2表示不是首次去这个地方
xn[n] = lasts
n = n + 1
with open(file=url, mode='w', encoding="utf-8") as data2:
data2.write(str(date) + "\n")
for x in range(0,n-1):
data2.write(str(xn[x]) + "\n")
data2.write(str(qq) + "\n")
data2.write("-1\n")
return 1 #1表示首次去这个地方
def checkplace(qq):
check = os.getcwd()
location = os.path.abspath(os.path.join(os.path.dirname(__file__), 'place', str(qq) + '.txt'))
if not os.path.exists(location):
with open(file=location, mode='w', encoding="utf-8") as data:
data.write("0\n")
data.close()
with open(file=location, mode='r', encoding="utf-8") as data:
place = data.readline()
place = place.strip()
return place