1. 正常编写一个py文件,假设为mypy.py, 其中有三个函数,依次为A(),B(),C()
2. 新建一个目录,把py文件复制到该目录中
3. 在目录中新建setup.py文件, 内容如下
from distutils.core import setup
setup(
name = "mypy",
version = "1.0.0",
py_modules = ["mypy"],
author = "yourname",
author_email = "yourname@hs.cn",
url = "http://www.yourname.com",
description = "a simple example"
)
4. 在命令提示符下依次执行
python setup.py sdist
python setup.py install
5. 如在一个新的py文件x.py中引用mypy.py, 可以采用如下方式
import mypy
mypy.A()
mypy.B()
2. 新建一个目录,把py文件复制到该目录中
3. 在目录中新建setup.py文件, 内容如下
from distutils.core import setup
setup(
name = "mypy",
version = "1.0.0",
py_modules = ["mypy"],
author = "yourname",
author_email = "yourname@hs.cn",
url = "http://www.yourname.com",
description = "a simple example"
)
4. 在命令提示符下依次执行
python setup.py sdist
python setup.py install
5. 如在一个新的py文件x.py中引用mypy.py, 可以采用如下方式
import mypy
mypy.A()
mypy.B()