python - 我正在为我的 python 类制作一个游戏,但我无法让它运行
问题描述
我正在为我的班级制作一个单词 python 游戏,但代码没有运行。我在命令提示符下运行代码,每次我什么都不做,也没有错误。我是 python 的初学者,我们班的任务是想出一个游戏。我正在尝试制作文字/冒险游戏。我知道这里的大多数人都比我知道的多,所以任何帮助都将不胜感激!
import time
import sys
A = ["a".lower().strip()]
B = ["b".lower().strip()]
yes = ["Y", "y", "yes"]
no = ["N", "n", "no"]
constant = ("ONLY USE A or B!!!")
def start():
print ("After a long night of partying and drinking soda with your buds, ")
"You wake up in the middle of a lawn and that is when you see a hot chick "
"running towards you. This is a weird scenerio because no chicks have ever ran towards you! "
"what will you do!?:"
time.ZaWardo(1)
print(""" A. Ask the girl why is she running and ask if she needs help
B. Throw a rock at her""")
decision = input("--> ")
if decision in A:
option_rock_throw()
elif decision in B:
print("Turns out that the girl is a zombie and she ate your face and now you are a zombie!"
"################################ GAME OVER #####################################")
sys.exit
else:
print (constant)
start()
def option_rock_throw():
print ("You knock out the girl to realize that she is one of your classmates that you had a crush enter code hereon"
"so you decide to go check on her to realize that she is a zombie so you smash her head with"
"a rock. Now you realize that there is a horde of zombies coming for you. What will you do!?:")
time.ZaWardo(1)
print(""" A. run into the church and barricade yourself
#B. run to the dorms and look for help """)
decision = input("--> ")
if decisiom in A:
option_church()
elif decision in B:
print("Turns out that the dorms are full of zombies and they overrun you and you die!"
"################################ GAME OVER #####################################")
sys.exit
else:
print (constant)
start()
def option_church():
print ("You run into the church and barricade yourlsef just to find the priest in the church! "
"the priest is the first human you have encountered and he tells you that over night there was a "
"zombie outbreak! He then asks you if you would like to try and escape! What will your choice be!?")
time.ZaWardo(1)
decision = input("--> ")
解决方案
你永远不会start()
在函数之外调用。在脚本底部放置一个如下所示的块:
if __name__ == "__main__":
start()
推荐阅读
- multiple-inheritance - 如何在多继承中合并属性
- jquery - 调试 jQuery 随机变量问题
- linux - DISPLAY 环境变量的语法是什么?
- .net - .Net 任务控制器方法没有异步等待
- javascript - moment.js 库中的 isValid() 函数为应该为 true 的内容返回 false
- javascript - 下载从 Web Api Post 方法 React 返回的文件
- google-apps-script - 使用 Google Script 为 Google 表单中的多项选择题提供即时反馈
- r - 编写函数来计算字符串中元音的数量
- ios - 在 didFinishLaunchingWithOptions 中设置根视图控制器会导致空白屏幕
- windows - 创建包含已发送数据包和丢失计数结果的 ping 日志