我是一名Python初学者,我试图编写一个基本上是使用函数的“算命先生”的程序。我在调用函数get_today()时遇到了一个问题,该函数被编写为在每月的某天为用户输入一个输入,并将其作为整数返回。尝试调用函数时发生错误
然而,当我呼吁功能提示我与云的错误:
TypeError: get_today() missing 1 required positional argument: 'd'
我试着打了一下周围,不能弄清楚这是什么意思。这里的主要功能是:
def main():
print("Welcome to Madame Maxine's Fortune Palace. Here, we gaze deeply into your soul and find the secrets that only destiny has heretofore known!")
print("")
print("The power of my inner eye clouds my ability to keep track of mundane things like the date.")
d = get_today()
print("Numerology is vitally important to fortune telling.")
b = get_birthday()
if(d >=1 and d <= 9):
print("One more question before we begin.")
a = likes_spicy_food()
print("I will now read your lifeline")
read_lifeline(d,b,a)
if(d >= 10 and d <= 19):
print("I will now read your heartline.")
read_heartline(d,b)
if(d >= 20 and d <= 29):
print("I need one last piece of information.")
m = get_birthmonth()
read_headline(b,m)
if(d == 30 or d == 31):
print("Today is a bad day for fortune telling.")
print("These insights into your future are not to be enjoyed or dreaded, they simply come to pass.")
print("Good day.")
main()
这个问题很可能会重复,当第二功能get_birthday()被调用,询问他们出生一个月的日子用户。
这里是get_today的代码片段():
def get_today():
x = int(input("Tell me, what day of the month is it today:"))
return x
帮助将大规模感激!
一方面,功能'get_today'需要一个参数,但是当你所有它'main',你不给它任何参数。看起来你实际上并不需要'get_today'的参数,所以在'def get_today(d):' – jss367
中删除'd'那么当你调用'get_today'时,你没有向它传递参数一开始... – toonarmycaptain
删除d提示我一个新的错误'TypeError:get_today()缺少1所需的位置参数:'d'' – dezz