There isn't any need to add file.py
while importing.
(导入时无需添加file.py
)
Just write from file import function
, and then call the function using function(a, b)
. (只需from file import function
写入,然后使用function(a, b)
调用该函数。)
The reason why this may not work, is because file
is one of Python's core modules, so I suggest you change the name of your file. (这可能不起作用的原因是因为file
是Python的核心模块之一,所以我建议你更改文件的名称。)
Note that if you're trying to import functions from a.py
to a file called b.py
, you will need to make sure that a.py
and b.py
are in the same directory.
(请注意,如果您尝试将函数从a.py
导入到名为b.py
的文件中,则需要确保a.py
和b.py
位于同一目录中。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…