Module what is a module: Files that include Python code are called Modules 1. The role of the module: sharing, easy to use 2. Creation, installation and release of modules
a. Put the module file in a directory
B.Add the setup.py file to this directory
C. Edit the setup.py file like this: from Distutils.core import setupsetup (name= "Lcmnester", Version= "1.0.0", py_modules=["Lcmnester"], author= "Luocaimin", author_email= "[Email protecte D] ", url=" http://www.vvvrrr.com ", description=" luocm ' s Printer of nested list ",)
D. Build the Publish file, run the path at the command line/python.exe setup.py sdist
e. Install to the local copy of Python, run the path at the command line/python.exe setup.py install
F. Register PyPI, then register at the command line, execute the path/python.exe setup.py register (only once) on the command line
g. Upload code, run at command line path/python.exe setup.py sdist upload Post-release catalogue comparison 3. Comments: Single or multiline comment: "" "Content" "" (not assigned to variable) single-line comment: #content (if placed in "" "" is not a comment) 4. Through the import sys in idle; Sys.path can view the path and order of the search module 5. namespace python The code of the main program is associated with the namespace __main__, and the separate module Python creates the namespace with the same name as the module. Its functions require a namespace-qualified invocation. Name of the namespace. Function name. bif functions are not imported, Bif are __builtins__ namespaces, will be automatically imported into the __main__ namespace, and __main__ namespaces will be automatically imported into each Python idle. 6. Module import, you can import all functions under a module Import module name (function requires limited access), you can also import a function under a module from the module name import function name Add this function to the current namespace (no qualifying access) to the 7.pyc file, which is equivalent to the Java. class file, which is an intermediate byte file, and Python converts the code file to the PYc file (compile and optimize) as needed. 8.python will run the code as much as possible. 9. Default parameters: Def function_name (param=1): 10.bif rang (), eg:for I in range (ten) ; for i in range (2,7); For I in range (2,7,2) 11. Contains end= "as a PRINT is a parameter that can change the output default terminator (default is newline)
Python Learning note seven