当前时间在代码开始时使用...定义
from datetime import datetime
now = datetime.now()
auformat = now.strftime("%d-%m-%Y %H:%M:%S")
# print(auformat)
我需要停止输入并发约会并停止插入过去的约会。这是我的代码,但我不知道该把它放在哪里,因为它需要位于下面的“addRecord”代码中的“日期、开始、结束”之后。
def isConcurrentAppointment(date, start, end):
if isConcurrentAppointment(date, >=appt.start, >=appt.end): # greater than or equal to
print("Cuncurrent appointment exists. Try again.")
continue
elif appt.start <=now: # OR <=current.time: - Not sure what to use
print("Invalid entry. Appointment must be in the future. Try again!")
continue
输入(addRecord)代码
def addRecord(schedule):
date = input("Enter a date (DD/MM/YYYY): ")
date = date.strip()
start = input("Enter a start time (HH): ")
start = start.strip()
end = input("Enter an end time (HH): ")
end = end.strip()
'''
I think the above code should slot in here somehow!
'''
description = input("Enter a description (Max. 25 characters with spaces): ")
venue = input("Enter a venue (Max. 25 characters with spaces): ")
priority = input("Enter a priority (High, Medium or Low): ")
priority = priority.strip() # if isConcurrentAppointment statement goes maybe below here.
appointment = Appointment(date,start,end,description,venue,priority)
schedule.append(appointment)
print("Appointment added.")
如前所述,我创建了要插入的代码,但无法确定插入位置,因为它有一个“def”语句。也许我需要以某种方式失去“def”行?
def isConcurrentAppointment(date, start, end):
if isConcurrentAppointment(date, >=appt.start, >=appt.end): # greater than or equal to
print("Cuncurrent appointment exists. Try again.")
continue
elif appt.start <=now: # OR <=current.time: - Not sure what to use
print("Invalid entry. Appointment must be in the future. Try again!")
continue
一般来说,您可以通过以下方法确定所请求的预约是否与任何其他现有预约重叠。