对python模块中多个类的用法详解
如下所示:
importwuhan.wuhan11 classHan: def__init__(self,config): self.batch_size=config.batch_size self.num_steps=config.num_steps classconfig: 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
Processfinishedwithexitcode0
刚学习Python,所以一点点学会的东西都想要记载怕秀逗脑袋瓜记不住:
感悟:
1.batch_size和num_steps可以理解成类Han的成员变量
2.class类型可以不用实例化直接作为参数使用
3.模块中可以有多个类
以上这篇对python模块中多个类的用法详解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持毛票票。
热门推荐
10 财运虎年祝福语简短语
11 单亲爸爸春节祝福语简短
12 狗狗上厕所训练
13 植物种植祝福语简短
14 翻译考试祝福语朋友简短
15 个人周年庆简短祝福语
16 狗狗怎么训练
17 分别祝福语简短搞笑英文
18 生日广州男生祝福语简短