Python在同一文件夹的导入文件中看不到功能

时间:2019-04-30 02:14:34

标签: python-3.x python-import

我有2个文件位于同一文件夹中。我想使用另一个文件中的功能。我正在将文件1导入文件2,并尝试在其中使用函数,如下所示:

文件1:

def foo()

file2

import file1

file1.foo() 

我收到此消息:

AttributeError: module 'parser' has no attribute '__all__'

我也尝试导入如下功能:

from file1 import foo

file1.foo()

但随后我收到此消息:

ImportError: cannot import name 'foo'

我做错了什么? python版本3.6.5

0 个答案:

没有答案