main.py
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?'
2 番目の単語 (パラメーター) を指定せずに「examine」と入力すると、エラーが発生します。
>>: 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 . . .
理由はわかりましたが、どうすれば直りますか?