import time
dictionary = {}
def add():
x = int(raw_input("Please enter the hour of your event in 24 hour time"))
y = raw_input("Please enter the name of your activity")
dictionary[x] = y
print (dictionary[x] + " was added succesfully")
main()
def view():
theTime = time.localtime()
print "the hour is: ", theTime.tm_hour
theHour = theTime.tm_hour
x = dictionary.keys()
if x in dictionary:
print "The current event is", x
print "Your full shcedule for today is: ", dictionary
main()
def remove():
print dictionary
x = int(raw_input("which time slot would you like to clear?"))
z = dictionary.pop(x)
print z + " was removed"
main()
table = {
1 : add,
2 : view,
3 : remove
}
def run(x):
table[x]()
def main():
x = int(raw_input("Please select and option! \n\n1. Add an event \
\n2. View an event \n3. Remove an event \n4. Exit"))
if x == 4:
exit()
run(x)
main()
好吧,所以唯一对我不起作用的是视图功能。添加事件后,然后我尝试查看它,我得到一个不可散列的类型:“列表”错误。为什么会这样,我该如何解决?谢谢