1. Module
1. In Python, a. py file is called a module.
2. Large Greatly improves the maintainability of the code.
3. Writing code does not have to start from scratch. When a module is written, it can be referenced elsewhere
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M00/9B/EE/wKioL1lo0KaR-BsyAABCJMRCmbs721.png "title=" 50RCY ]iyfqpb3duehk ' J}s5.png "alt=" Wkiol1lo0kar-bsyaabcjmrcmbs721.png "/>
2. Package
* What if different people write the same module name? To avoid conflicting module names, Python introduces a way to organize modules by directory, called packages
* Steps to create a package:
(1) Create a directory for the package name;
(2) Under this folder, create a __init__.py file to store the package information, the file can be empty ;
(3) To store script files, compiled extensions and sub-packages as required;
650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M02/9B/EE/wKioL1lo0T-S108PAAAVocXZU3A795.png "title=" RX} Nwt%z (7f8nqrkls@]vaq.png "alt=" Wkiol1lo0t-s108paaavocxzu3a795.png "/>
* Use of the package
650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M02/9B/EE/wKioL1lo05-iIb0UAAASzdKInv8027.png "title=" T_ 88PQ{V~K) u1xma13[kk) c.png "alt=" Wkiol1lo05-iib0uaaaszdkinv8027.png "/>
3. Three ways to call the module
(1) Import Manu direct call module
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M00/9B/EE/wKioL1lo0mmwQWfzAAAyQqfnZ7o178.png "title="}d$ck _w9 (yajk2k4s9~28@s.png "alt=" Wkiol1lo0mmwqwfzaaayqqfnz7o178.png "/>
(2) method in the From Manu Import add call module
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M00/9B/EE/wKioL1lo0o-Ao_hDAAA3HoSZ6oA773.png "title=" 5$% 48u[]kylu ' Odbbx (fos.png "alt=" Wkiol1lo0o-ao_hdaaa3hosz6oa773.png "/>
(3) From Manu Import add as Myadd call the method in the module and rename
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/9B/EE/wKioL1lo0sbRoycYAABCN5lRmj0224.png "title=" xu0[ nj~x)%4ot$%ax0{2xh6.png "alt=" Wkiol1lo0sbroycyaabcn5lrmj0224.png "/>
4. Module Search Path
1. When we try to load a module, Python searches for the corresponding. py file under the specified path;
2. By default, the Python interpreter searches the current directory, all installed built-in modules, and third-party modules, and the search path is stored in the PATH variable of the SYS module .
650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M00/9B/EF/wKiom1lo09GDfOtEAAC9W-N3Swk687.png "title=" Iae@qd~d%zka9q[uqn]2sdr.png "alt=" Wkiom1lo09gdfoteaac9w-n3swk687.png "/>
3. Add the search path, which is temporary in bash.
650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M01/9B/EE/wKioL1lo1B3SppMtAACQqwE7XNI422.png "title=" 3) xdy8dj7e9u) @L4JSCX05T. png "alt=" Wkiol1lo1b3sppmtaacqqwe7xni422.png "/>
Python Modules and Packages