Python3 module, package call & Path details, python3 module package call
As follows:
The following code is used to explain the advantages of the ''''' Infi_chu ''' module in the blog Park: 1. high maintainability 2. there are three modules that can greatly reduce the amount of code written: 1. python standard library 2. third-party Module 3. application custom module ''' # import example # Call example Module # from example import example # Call an example method ''' Infi_chu ''' In the example module '''''' package features: 1. there are _ init __. py file 2. there are many modules consisting of ''' # from test import example # test is the package name, example Module name, a layer of nesting # from test. test1 import example # test1 and test2 are both package names. test1 is in test, and example is the module name # from test. test1.func1 import example # func1 is a func1 method in the example Module # import test # test indicates the package name, this command is equivalent to executing the _ init _ file '''blog Infi_chu ''''' import package or the difference between modules. The import package only executes a _ init __. the py file is not associated with other modules. to call the import module, call the ''''' path of the module to solve ''' # import sys, OS # a = OS. path. abspath (_ file _) # obtain the absolute path # print (a) # print (OS. path. dirname (a) # obtain the path of the previous layer # base_dir = OS. path. dirname (OS. path. dirname (a) # obtain the path of the previous layer # print (base_dir) # sys. path. append (base_dir) ''' Infi_chu '''
The above Python3 module, package call, and detailed path are all the content shared by Alibaba Cloud. I hope you can provide a reference and support for the customer's home.