When we import a module: import XXX, by default the python parser will search the current directory, installed built-in modules and third-party modules. The search path is stored in the path of the sys module:
import sys
sys.path
output:
['d:\\program\\anaconda3\\envs\\learn_py36\\python36.zip',
'd:\\program\\anaconda3\\envs\\learn_py36\\DLLs',
'd:\\program\\anaconda3\\envs\\learn_py36\\lib',
'd:\\program\\anaconda3\\envs\\learn_py36',
'',
'd:\\program\\anaconda3\\envs\\learn_py36\\lib\\site-packages',
'd:\\program\\anaconda3\\envs\\learn_py36\\lib\\site-packages\\win32',
'd:\\program\\anaconda3\\envs\\learn_py36\\lib\\site-packages\\win32\\lib',
'd:\\program\\anaconda3\\envs\\learn_py36\\lib\\site-packages\\Pythonwin',
'd:\\program\\anaconda3\\envs\\learn_py36\\lib\\site-packages\\IPython\\extensions',
'C:\\Users\\DELL\\.ipython']
can see that the result is a list, that is, we use import to import the module, in the list of these contents to search. So sys.path.append() brackets fill in the path to import the module, and then you can import the module using the import module.
os.path. Exists () :
OS operating system (operating system), Python OS module encapsulates the system files and file paths. The
os.path module is mainly used for obtaining file properties. Exists means “exists”, so os.path. Exists () is used to determine the existence of a file in parentheses. For all files in the system and their paths, you can determine.
returns: True or False
OS. Path. The join () : </ strong>
OS. The path. The join (” father “, “subset”)
the returned result is:
father set subset \ ‘
meaning to add “subset” to “father” after the path.
os.makedirs() :
create folders under the current path: subset
can also write absolute paths:
os.makedirs(‘C:\Users\DELL\Desktop\ subset)
create folders named as subsets on the Desktop.
Read More:
- Android More than one file was found with OS independent path ‘META-INF/LICENSE‘
- Android:More than one file was found with OS independent path ‘res/values/values.xml
- Relative path and absolute path${ pageContext.request.contextPath }
- Python program exit: OS_ Exit() and sys.exit ()
- ClobberError: The package ‘xxx‘ cannot be installed due to a path collision for ‘xx‘ This path alre
- Configuring OpenGL environment on Mac OS
- Fatal: unable to create ‘project_ path/.git/ index.lock ‘: File exists.
- Windowserror: [error 183] error and in Python os.raname () detailed explanation
- Instability of Mac OS finder
- os.remove (file) error windowserror: [error 32]
- A call to an OS function failed
- Installing nmap on Mac OS
- Take over the project, the project path is inconsistent with the native UE4 path and the solution of Failed to open descriptor file ..//..//..//UE4/UE4.uproject
- Solution for error 7 in lineage OS brush
- AttributeError: module ‘os‘ has no attribute ‘fork‘
- The solution of GDB code designed problem in Mac OS X
- Dm7 Dameng database dmrman reports an error OS_ pipe2_ conn_ Server open failed solution
- Big hole in using OpenGL on Mac OS
- Error prompt of MAPP opening PHP under Mac OS
- Red rice note3 (Kenzo) is brushed into lineage OS