Structural uses of the specification:
1. High readability
2. High maintainability
Brief introduction of the document:
1.bin/: Store Some executable files of the project, of course you can name acript/or something.
2.foo/: Store The source code of the project:
(1) All modules in the source code, the package should be placed in this layer directory
(2) Its sub-directory tests/Store unit test code
(3) The entrance of the program should be named main.py
3.docs/: Storing some documents
4.setup.py: Installation, deployment, packaged scripts
5.requirements.txt: List of external Python treasures since the software was stored
6.README: Description file for Project
1. Locate the current file path
Relative path: The terminal can view the path of the required file,
Print (__file__)
PWD, the output function results in a relative path.
2. Import the library file and find the parent file path
3. Functions that call the main file
ImportOSImportSYS#how to find the offspring of the Fathers#How to get the path to the current filePrint('-----Relative Path-----')#relative path: Execute command under terminal, enter file Python atm.pyPrint(__file__)Print('-----Absolute Path: The OS library needs to be imported-----')#If you want the absolute path of the current file, import the library OSPrint(Os.path.abspath (__file__))Print('-----father-level directory-----')#top-level path on current filePrint(Os.path.dirname (Os.path.abspath (__file__)))Print('-----Grandfather Category-----')#Grandfather Level CataloguePrint(Os.path.dirname (Os.path.dirname (Os.path.abspath (__file__))))#Grandpa Level directory pathBase_dir = Os.path.dirname (Os.path.dirname (Os.path.abspath (__file__)) ) sys.path.append (base_dir)#Import Configure,core#Import the required file name from the uncle's level directory fromConfigureImportsetting fromCoreImportMain#file Fetch functionMain.login ()View Code
def login (): Print ('Welcome to my mainfunction') Print ('Check---')
View Code
Python project structure specifications and calls between files