【发布时间】:2014-12-02 14:15:05
【问题描述】:
我编写了一个函数wczytaj 来获取所有参数,我想将它们返回给构造函数,但它不能以这种方式工作。我想知道为什么不以及如何解决它
我收到此错误:
TypeError: wczytaj() missing 3 required positional arguments: 'a', 'b', and 'c'
不可能写一个函数,返回3个参数吗?
from math import sqrt
def wczytaj(a , b , c):
a = input("Podaj parametr A? ")
b = input("Podaj parametr B ")
c = input("Podaj parametr C? ")
return a , b , c
class Rk:
def __init__(self,a,b,c):
self.a = a
self.b = b
self.c = c
nowe = Rk(wczytaj())
print("Ten program rozwiązuje równanie kwadratowe po podaniu parametrów.")
print("\n Równianie jest postaci {}x*x + {}x + {} = 0 ".format(a, b, c), end="")
【问题讨论】:
-
你为什么不这样做as you've already been shown?我已删除“解释我 [OOP]” 的请求;这对 SO 来说太宽泛了。