有人能告诉我为什么我会犯这个错误吗?我认为代码没有问题,当我用Name,Start,End
替换**item
时,我仍然无法使它工作
print("To finish input enter nothing.")
Schedule = []
Finish = False
while not Finish:
Name = input("What is the name of the show?: ")
Start = input("What time does the show start?: ")
End = input("What time does the show end?: ")
Schedule.append({'Name':Name, 'Start':Start, 'End':End})
print("{0:<10} | {1:<10} - {2:<10}".format(Name,Start,End))
print("{Name:<10} | {Start:<10} - {End:<10} ".format(**item))
if len(Name) == 0 or len(Start) == 0 or len(End) == 0:
Finish = True
这个代码对我来说很好,除了你没有定义项?
假设该项是某种容器(名称、开始、结束),则需要将此行更改为:
这样你就不用键了,它可以按顺序填充字段。 或:
如果你真的想用钥匙。
基本上,您的键错误是在没有为键提供值的情况下用键({Name:<;10})请求值。
希望能有所帮助。
你永远不会创建
item
。试试这个:
相关问题 更多 >
编程相关推荐