我做了一个模块来添加两个整数,但调用它给了我"none"答案



我是初学者,正在学习编程,

这里是Module:

class extfile:
def add(x, y):
return x + y

程序如下:

class A:
def a(x, y):
extfile.add(x,y)    
print(A.a(4,5))

输出:

没有

你的类A的方法A没有返回任何东西:

class extfile:
def add(x, y):
return x + y
class A:
def a(x, y):
return extfile.add(x,y)
print(A.a(4,5))
#output: 9

最新更新