python - 它说 NameError: name 'Doctor' is not defined 当我尝试执行
问题描述
#Program that outputs quote for 3 jobs and outputs a sorry message >if an unrecognised job is used
#Subroutine to describe job
def Desc(Job):
if Job == 1:
print("Seeing what other people cant see gives you great vision")
elif Job == 2:
print("Logical thinking, passion and perseverance is the paint on your palette.")
elif Job == 3:
print("The engineer has been,and is,a maker of history.")
else:
print("Sorry, we could not find a quote for your job")
Analyst = 1
Developer = 2
Engineer = 3
#Main program
Desc(Doctor)
解决方案
您没有设置变量“医生”。例如,您需要编写:
Doctor = 1
Desc(Doctor)
推荐阅读
- python - convert from year-month-date to year-Quarter in pandas
- python - 如何获取 Telegram chat_id?
- python - Python 抓取链接的父 URL,然后是这些链接的子 URL,然后是表数据并存储到可读文件中
- c - 使用 C 程序执行代码时支持从 db2/大型机返回值的可能数据类型是什么
- perl - Perl 自动化散列填充和键名
- list - 列表不会随 Ray 并行 python 改变
- python - 为什么我的模型没有通过我在 Tensorflow Keras 中的自定义层?
- c# - 带有 Azure 函数的 Swashbuckle - 定义查询参数
- dictionary - 如何获取 Pyspark 中每一行的字数字典?
- javascript - 本地代理应用程序作为 SaaS 的“窗口”?