版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Modulemaking2learningtasksMakeandusecustommoduletoprinttime.3KnowledgeobjectivesUnderstandthe__name__attributeMasterthestepsofmakingmodule01CapabilityobjectivesAbilitytomakeandusecustommodulesAbletomaintainanddebugmodulecode02Learningobjectives4ModulemakingstructureInPython,modulescanincludeexecutablecodeinadditiontomethoddefinitions.Thiscodeisgenerallyusedtoinitializethemoduleandwillonlybeexecutedwhenitisfirstimported.Whenamoduleisfirstintroducedbyanotherprogram,itsmainprogramruns.Ifyouwantaprogramblockinthemodulenottoexecutewhenthemoduleisintroduced,youcanusethe__name__Attribute.5Modulemaking__name__attributeTheuseofmodulescanbedividedintotwosituations:selfoperationandintroducedoperation.Eachmodulehasabuilt-in__name__Properties,via__name__==‘__main__’Theusageofthecurrentmodulecanbejudged.6Modulemaking__name__attributeWhenthemoduleitselfisuseddirectlyasascript__name__Valueis''__main__’,atthistime__name__==‘__main__’Iftheresultistrue,theprogramwillexecute.Whenamoduleisimportedforuseinanothermodule__name__Thevalueis'filename',atthistime__name__==‘__main__’Iftheresultisfalse,theprogramwillnotexecute.7ModulemakingExample1:Viewmodule__name__attribute8ModulemakingWhyuse__name__Use__name__Attributejudgmentcaneffectivelydistinguishtheinternalprogramofthemoduleandexposetheprogramforothermodules.Whenwritingamodule,youcan__name__==‘__main__’"Addsomedebuggingcodetoit,whichwillnotaffectthenormalcallingoftheexternalmodule,butalsodirectlyexecutethemodulefilewhentroubleshooting,soastofacilitatethedebuggingandmaintenanceofthemodulecode.9ModulemakingExample2:makingandusingcustommodule10Taskimplementation11Operationdemonstration12Summ
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年独立运行村用风力发电机组行业发展行业新材料创新报告及未来五至十年行业发展趋势分析报告
- 2026年金融科技行业创新解决方案及发展报告
- 2027届湖南省邵阳市北塔区化学九上期末达标检测试题含解析
- 江苏省南京市高淳区2027届化学九上期末综合测试试题含解析
- 2026年福建泉州现代中学招聘教师3人考前冲刺密卷及参考答案详解【综合卷】
- 2026广东湛江市看守所招聘监区伙房工作人员3人笔试题库附参考答案详解(夺分金卷)
- 2026新疆伊犁州奎屯市招聘公益性岗位1人(8-12)考前冲刺密卷附参考答案详解【能力提升】
- 2026西安博爱学校招聘考前冲刺试卷附参考答案详解(考试直接用)
- 2026上海奉贤区部分机关事业单位编外人员招聘61人岗位报名考前冲刺密卷附答案详解(黄金题型)
- 2026博州歌舞团招聘编制外演员(3人)模拟试卷含答案详解(夺分金卷)
- 2026辅警轮训考试题及答案
- 2026-2030中国蓄能器行业现状调查与未来发展前景预测研究报告
- 新闻记者职业资格考试题库(1000题含答案与解析)
- (2026秋新版)北师大版四年级数学上册全册教案
- 2026年河北省中考英语试卷真题及答案详解(精校打印版)
- 神经外科护理质量信息化管理探索
- 【2026 新教材】统编版一年级上册语文识字课教学设计(天地人、金木水火土)
- en590现货销售合同
- 2026年中考数学二轮复习 专题17 二次函数的综合压轴题(高频考点专练)
- 年产3600吨薯类食品生产线技术改造项目可行性研究报告模板拿地申报
- 2026电子工业出版社有限公司招聘应届高校毕业生12人笔试参考题库及答案解析
评论
0/150
提交评论