My test environmentpython 3.4
Questioner, I created a Project and tested it. The file structure is as follows:
project_test/
|---test.py
|---test
|---init.py
It can be seen that test is a package __init__.py:
pythonclass module_1:
print('This is a test!')
pass
When I import test in test.py, run
The output result is: This is a test
Note that when importthispackage occurs, the class is automatically instantiated. In this way, for your question, you should just call it directly~
Use absolute_import
My test environmentpython 3.4
Questioner, I created a Project and tested it. The file structure is as follows:
It can be seen that test is a package
__init__.py
:When I
import test
in test.py, runThe output result is:
This is a test
Note that when
import
thispackage
occurs, the class is automatically instantiated. In this way, for your question, you should just call it directly~import A