![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
tomorrow00hello
这个作者很懒,什么都没留下…
展开
-
python 打包
使用setuptools 打包。简单的安装脚本setup.pysetup.py from setuptools import setupsetup( name='Hello', version = '1.0', description = 'A simple example', py_modules = ['hello'])install命令把模块复制到PYTHONPATH指定的目录中python3 setup.py原创 2021-03-04 09:49:42 · 86 阅读 · 1 评论 -
python-在模块中添加测试代码
使用__name__变量来添加测试代码在主程序中,变量__name__的值是__main__,而在导入的模块中,这个变量是该模块的名称。#test.pydef test(): todo()if __name__ == '__main__' : test()测试代码放在函数test中,可在程序中导入模块并对其进行测试。>>>import test>>>test.test()...原创 2021-03-02 09:48:53 · 339 阅读 · 0 评论 -
python-文件的存储位置
个人编写的模块需要放在正确的位置,python才能够找到。1、sys.path>>> import sys>>> sys.path.append("/home/py/Documents")2、将模块放到正确的位置python默认的目录列表(即搜索路径)>>> import sys>>> print(sys.path)['', '/home/py/work/python', '/usr/local/pytho原创 2021-03-02 09:40:56 · 3897 阅读 · 0 评论