Python module
python modules are the basic way to organize your code
Python scripts are saved with a text file with the extension py, and a script can be run either alone or in another script. When a script is imported to run, it is called a module
Cat test.py
#!/usr/bin/python
#coding: Utf-8
From __future__ Import Division
def a (x, y):
Print X+y
def b (x, y):
Print X*y
Cat new.py
#!/usr/bin/python
Import Test
TEST.A (ON)
TEST.B (3,4)
Package
Python modules can be organized into packages by directory
The steps to create a package are:
--Create a folder named Package name
--Create a __init__.py file under this folder
--store script files, compiled extensions, and child packages under this folder as needed
mkdir/python/
touch/python/__init__.py
VI test.py
#!/usr/bin/python
Import Python.test
Print Python.test.a
This article from "Meteor Yu" blog, declined reproduced!
Vii. python modules and packages