所以即时编写我从scholl得到的python脚本测试但由于某种原因它甚至没有开始...没有错误没有什么... 它应该是和雇用日志系统..使用线程为无限循环,应该计算min和创建检查时钟为“雇用”并在后台运行和另一个功能,如果他已经签署,则支持阅读雇用名称检查在或不,如果没有将他添加到具有时钟时间和名称的文件或相反的方式,将他注销但由于某种原因代码甚至运行,没有错误,没有什么只是空白运行屏幕,生病了很高兴得到一些帮助..
#!/bin/usr/python
from datetime import datetime
import threading
import time
users=open("logfile.txt","w")
def background():
seconde = 0
minute = 0
hour = 0
while True:
time.sleep(1)
seconde = seconde + 1
if seconde == 60:
minute = minute + 1
seconde = 0
elif minute == 60:
hour = hour + 1
minute = 0
alltime = str(hour) + ":" + str(minute) + ":" + str(seconde)
def foreground():
alin = []
name = input("Hello Deal employ , please insert your name:\n")
if name not in alin:
login=input("your not logged in , do you wish to log?\n")
if login == "yes" or "Y" or "y" or "Yes":
users.write("{} Entry Hour :".format(name) + alltime)
alin.append(name)
elif login == "no" or "N" or "n" or "No":
print("ok") and exit()
elif name in alin:
logout=input("Your allready signed in , do you wish to check out?\n")
if logout == "Yes" or "Y" or "Y" or "yes":
users.write("{} Leaving Hour :".format(name) + alltime)
elif logout == "no" or "N" or "n" or "No":
print("ok") and exit()
b = threading.Thread(name='background', target=background())
a = threading.Thread(name='foreground', target=foreground())
b.start()
a.start()
答案 0 :(得分:0)
b = threading.Thread(name='background', target=background())
target
应该是一个可调用的对象。在启动线程之前,您正在运行background
。由于background
永不停止,您的程序将永远运行。尝试:
b = threading.Thread(name='background', target=background)
我不确定你要做什么,但我很确定它不会起作用。