python初体验

金角大王 的课程确实不错。spa

从第一节课做业写起。直接看吧。code

 

 

 1 import sys
 2 user_name = "alx"
 3 password = 123456
 4 import time
 5 
 6 import os
 7 if os.access("lock.txt", os.F_OK):
 8     with open('lock.txt') as read_file:
 9         old_time = read_file.read().strip()
10         old_time = float(old_time)
11 
12     new_time = time.time()
13     time_difference = new_time - old_time
14 
15     if time_difference <400:
16         print ("系统锁定中,请5分钟后再试!")
17         sys.exit(0)
18 
19 
20 for i in range(3):
21     guest_name = input("plesea you name")
22     if guest_name == user_name:
23         print ("姓名匹配成功!")
24         guest_password = int(input("plesea you password"))
25         if guest_password == password:
26             print ("恭喜登陆成功")
27             break
28         else:
29             print ("密码输入错误,请重试")
30     elif i == 2:
31         print("机会用完了!你是猪吗")
32         time_save= open("lock.txt","w+")
33         time_save.write(str(time.time()))
34     else:
35         print("姓名未查询到,请核实!")
相关文章
相关标签/搜索