Python模块
2016-06-12 14:51
405 查看
1.引入其他模块
或者
当一个模块被第一次输入的时候,这个模块的主块将被运行。
如果我们只想程序本身被使用的时候运行主块,而在它被其他模块输入的时候不运行主块
编写primtme.py
编写printmeTest.py
2.查看模块中内容
dir(模块名)
3.模块安装
from printme import sayHi sayHi()
或者
import printme printme.sayHi()
当一个模块被第一次输入的时候,这个模块的主块将被运行。
如果我们只想程序本身被使用的时候运行主块,而在它被其他模块输入的时候不运行主块
编写primtme.py
def sayHi(): pass if __name__ == '__main__': print 'This is run by self' else: print 'This is run by other module'
编写printmeTest.py
import printme printme.sayHi()
2.查看模块中内容
dir(模块名)
3.模块安装
python setup.py install
相关文章推荐
- python环境搭建大致步骤
- Python文本(字面值)
- 将自定义python模块增加到类库搜索路径下面
- Python 元组详解
- Python 解析配置模块之ConfigParser详解
- python列表详解
- 配合Python3.5怎么成功安装64位的Pygame?
- 安装python2.7
- 机器学习算法---无监督学习,k-means聚类
- Python内存结构
- 用Python写一个简单公众号
- python支持中文
- python实现发送email
- python2.0_s12_day9_事件驱动编程&异步IO
- python中MySQLdb模块用法实例
- Python学习路程day19
- python中的not具体使用及意思
- [leetcode]Generate Parentheses 生成圆括号 python实现
- python 遍历select的option选项
- python简单爬虫(一)