我写这个作为例子:
def function():
choice = raw_input("> ")
if choice == "attack":
print "Killed the monster."
elif choice == "run":
print "You run but the monster follows you. Activate jetpack? (y/n)"
def function_in_function():
choice = raw_input("> ")
if choice == "y":
print "You fly to safety."
elif choice == "n":
print "You get stomped."
else:
print "That's not an option."
function_in_function()
else:
print "That's not an option."
function()
我在电源外壳上打开它但没有出现?
答案 0 :(得分:0)
我想这是您想要的功能和格式。我不建议在这里使用函数函数,因为它没有必要,但它仍然可以如图所示完成。记住缩进。在这里阅读http://www.python-course.eu/python3_blocks.php。此外,在分配之前无法调用函数。
README
编辑:根据评论。