The project structure is as follows:
test1.py
class A:
def a1(self):
print('aaa')
def a2(self):
print('a2222')
test2.py
class B:
def b1(self):
print("dddd")
test3.py
class C:
def c1(self):
print('ccc')
def c2(self):
print('a2222')
test4 is the test file
The __init__.py file in the pack1 directory is empty:
import sub1.test1 and sub1.test2 from test4, you can find:
uncomment the pack1, and then import the package to find:
Note: When import pack1 is executed, the __init__.py file under the package will be executed, and you can directly use [package name.method] to directly access the methods in the class, such as pack1.A()