我需要实现一个分派字典类型并打印出来,我现在有一个打印问题,,我需要打印David 1条目,但是我得到了一个例外,我如何打印它--这个函数有问题printRecord()
def make_medical_Record(name,num):
medical_Record = {}
def inData(act):
if act in medical_Record:
return True
return False
def addData(time,act):
if act in medical_Record:
medical_Record[act].append(time)
medical_Record[act].sort()
else:
medical_Record[act] = [time]
def view(value):
print(medical_Record.get(value)) if medical_Record.get(value) else print("no events")
def printRecord():
def hasMore():
return
def next():
return
print(min(min(medical_Record,key=medical_Record.get())))
instance = {'inData': inData,'notInData': notInData,'addData': addData,'view':view,'printRecord':printRecord }
return instance
mr=make_medical_Record('David',1)
print(mr)
mr['addData']('15:00','hospital discharge')
pr=mr['printRecord']()发布于 2021-12-07 18:30:08
您的printRecord函数看起来无效:
def printRecord():
def hasMore():
return
def next():
return
print(min(min(medical_Record,key=medical_Record.get())))很难从这段代码中确切地看出它应该做什么,但是您可以使用它作为一个起点来打印记录对象中的所有数据:
def printRecord():
print(name, num, medical_Record)https://stackoverflow.com/questions/70265001
复制相似问题