我有一个存储所有.py文件的目录.
bin/
main.py
user.py # where class User resides
dir.py # where class Dir resides
Run Code Online (Sandbox Code Playgroud)
我想在main.py中使用user.py和dir.py中的类.
如何将这些Python类导入main.py?
此外,User如果user.py位于子目录中,如何导入类?
bin/
dir.py
main.py
usr/
user.py
Run Code Online (Sandbox Code Playgroud) 我有两个文件,node.py并且path.py,它定义了两个类,Node并Path分别.
到目前为止,Path引用该Node对象的定义,因此我已经完成了
from node.py import *
Run Code Online (Sandbox Code Playgroud)
在path.py文件中.
但是,截至今天,我创建了一个Node引用该Path对象的新方法.
我在尝试导入时遇到了问题path.py:我尝试过,当程序运行并调用使用的Path方法时Node,一个异常上升,Node因为没有定义.
我该怎么办?