【发布时间】:2019-02-07 08:16:43
【问题描述】:
为什么我们在这里使用len(command),如果有人能解释我们在这里做了什么,那就太好了(整个事情,它变得复杂了..)
def get_input():
command = input(": ").split()
verb_word = command[0]
if verb_word in verb_dict:
verb = verb_dict[verb_word]
else:
print("Unknown verb{}" .format(verb_word))
return
if len(command) >= 2:
noun_word = command[1]
print(verb(noun_word))
else:
print(verb("nothing"))
def say(noun):
return 'You said "{}"' .format(noun)
verb_dict = {
"say" : say,
}
while True:
get_input()
我无法理解这里的全部内容,我需要解释一下我们上面创建的函数..
【问题讨论】: