项目的结构时
lib------
|--__init__.py
|
|--page.py
我在 __init__.py中定义了一个class A,请问怎么在page.py中导入这个类?
注意在python3.4环境中。
高洛峰2017-04-17 15:03:15
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
:
python
class 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 import
thispackage
occurs, the class is automatically instantiated. In this way, for your question, you should just call it directly~