我有一个函数,我正在制作另一个需要调用第一个函数的函数。我没有 Python 方面的经验,但我知道在像 MATLAB 这样的语言中,只要它们在同一目录中就可以了。
一个基本的例子:
def square(x):
square = x * x
Run Code Online (Sandbox Code Playgroud)
(并保存)
现在在我的新函数中,我想使用我尝试过的函数 square:
def something (y, z)
import square
something = square(y) + square(z)
return something
Run Code Online (Sandbox Code Playgroud)
其中显示:builtins.TypeError: 'module' object is not callable。
我该怎么办?