<p>你的程序重新启动,因为你的导入都错了。我不知道正确的输出应该是什么,但我解决了你的代码,所以它不会重新启动之前,做它应该做的事。我希望这有帮助。最后,您需要将两个文件放在同一个目录中,这样它们才能正常工作。你知道吗</p>
<p>你知道吗主.py你知道吗</p>
<pre><code>import random
import os
import sys
import cave
foodamount = random.randint(1,10)
def main():
global foodamount
answer = str(input(("Right or Left")))
if answer == "Right" or answer == "right":
#Check if foodamount is greater than 1, then if it is run cave.py
foodamount = foodamount -1
if foodamount < 1:
print("You ran out of food. You lose", foodamount)
sys.exit()
elif foodamount > 0:
os.system('python cave.py')
main()
</code></pre>
<p>你知道吗洞穴.py你知道吗</p>
<pre><code>import random
import sys
import os
from Main import *
print("You are in a cold section of the cave")
print("You see a spider in front of you")
print("Do you want to attack?")
attak = str(input(("Yes or No")))
if attak == "Yes" or attak == "yes":
x = random.randint(1,2)
if x == 1:
os.system('python attack')
if x == 2:
print("You lose")
sys.exit()
if attak == "no" or attak == "No":
print("Do you leave the cave or go around the spider?")
y = str(input("Leave or Around"))
if y == "Leave" or y == "leave":
foodamount = foodamount -1
if foodamount < 1:
print("You ran out of food. You lose")
sys.exit()
else:
os.system('python test')
</code></pre>