主文件
import engine
engine.objects['key'] = "It's a key"
engine.main()
引擎.py
# inventory = []
objects = {
}
def main():
while True:
choice = raw_input(">>: ")
command, obj = choice.split()
if command == 'examine':
if obj in objects:
print objects[obj]
else:
print 'joking right?'
else:
print 'joking right?'
当我键入没有第二个单词的“检查”参数时,它给了我一个错误。
>>: asdf
Traceback (most recent call last):
File "main.py", line 3, in <module>
engine.main()
File "C:\Users\Patrick\Documents\Programming\Game engine test\engine.py", line
11, in main
command, obj = choice.split()
ValueError: need more than 1 value to unpack
Press any key to continue . . .
我明白为什么,但我该如何解决呢?