a.py
def test():
print("hi")
b.py
from a import test
test('hello')
错误:
<块引用>导入错误:无法从 'a' (C:\mypath\a.py) 导入名称 'test'
或 b.py
import a
a.test('hello')
错误:
<块引用>属性错误:模块“a”没有属性“test”
提前致谢!
编辑:我试图在我电脑上的另一个目录中运行脚本,所以它不是因为路径或其他原因。另外,os.getcwd() 不起作用
答案 0 :(得分:0)
a.py 和 b.py 必须在同一个项目文件夹中。