python模块中多个类用法
2016-12-18 19:53
302 查看
import wuhan.wuhan11 class Han: def __init__(self, config): self.batch_size = config.batch_size self.num_steps = config.num_steps class config: batch_size = 10 num_steps = 50 if __name__ == '__main__': han = Han(config) print(han.batch_size) print(han.num_steps)
输出结果:
/home/ubuntu/workspace/pythondemo/env/bin/python /home/ubuntu/workspace/BioEvent/wuhan/Han.py
10
50
Process finished with exit code 0
刚学习Python,所以一点点学会的东西都想要记载怕秀逗脑袋瓜记不住:
感悟: 1. batch_size和num_steps可以理解成类Han的成员变量
2. class 类型 可以不用实例化直接作为参数使用
3. 模块中可以有多个类
相关文章推荐
- python 中的matplotlib.pylot 模块中的plot 用法
- python模块:win32com用法详解
- Python signal模块包介绍和用法
- python time模块用法实例详解
- Python常用模块用法分析
- python中计时工具timeit模块的基本用法
- Python中itertools模块用法详解
- python-socket模块基本用法收集
- python中re模块的用法
- python中bisect模块用法实例
- python模块:win32com用法详解
- python模块:win32com用法详解
- python中计时工具timeit模块的基本用法 分类: python python基础学习 2013-08-08 10:05 2072人阅读 评论(0) 收藏
- python os模块的主要用法
- python3.X中pickle类的用法(cPickle模块移除了)
- python之string模块的find用法
- python os模块的主要用法
- python模块:win32com用法详解
- python 中set模块的用法
- Python中itertools模块用法详解