问题遇到的现象和发生背景
python文件调用另一个文件里的函数,而那个函数又调用了另一个文件的函数,然后就报错了。
问题相关代码,请勿粘贴截图
以下为问题代码(与错误无关的代码已进行删减与修改)
main.py
from write.py import *
from new_open_delete.py import *
......
go()
write.py
from new_open_delete.py import *
def go():
print('1')
run()
new_open_delete.py
def run():
print(2)
运行结果及报错内容
Traceback (most recent call last):
File "E:/PY Project/pythonProject/Writing Novel/main.py", line 4, in <module>
from write.py import *
File "E:\PY Project\pythonProject\Writing Novel\write.py", line 2, in <module>
from new_open_delete.py import *
ModuleNotFoundError: No module named 'new_open_delete.py'; 'new_open_delete' is not a package