Questions:
Under the pre_tab.py file:
Print ("AA") from Import login1login1 ()
From test.te import login1this sentence in the program introduces the Login1 object (method) in the te.py file in the test directory under the current directorybut it's been an error importerror didn't find test.te this module
Traceback (most recent): " c:/users/administrator/pycharmprojects/laonanhai/shop_store/pre_tab.py " in <module> from import'test.te'
The reason for the lookup is that the __init__.py file was not created under the test directory (it was created by default, but I deleted it originally)
The __init__.py files is required to make Python treat the directories as containing packages; This was done to prevent directories with a common name, such as string, from unintentionally hiding valid modules That's occur later on the module search path. In the simplest case, __init__.py can just is an empty file, but it can also execute initialization code for the Package or set the __all__ variable, described later.
Slag Google translation: A __init__.py file is required to enable Python to treat the directory as a containing package; This is done to prevent directories with common names (such as strings) from accidentally hiding valid modules that appear later on the module search path. In the simplest case, __init__.py can be just an empty file, but it can also execute the package initialization code or set the __ALL__ variable, described later. Workaround: Build the __init__ (). py file in the test directory to supplement the views of others;as stated on the official website, this file allows this directory to be included in the current Python package,I understand it's becoming a module,import. This directory can be identified when the current directory is found, and then the import succeeds.
Python's Import subdirectory file