当前位置: 首页 > news >正文

做网站有什么框架个人网站构建

做网站有什么框架,个人网站构建,营销网络世界地图,手机网站建设策划书本文转载自公众号“读芯术”(ID#xff1a;AI_Discovery)。写代码必然会出现错误#xff0c;而错误处理可以针对这些错误提前做好准备。通常出现错误时#xff0c;脚本会停止运行#xff0c;而有了错误处理#xff0c;脚本就可以继续运行。为此#xff0c;我们需要了解下…本文转载自公众号“读芯术”(IDAI_Discovery)。写代码必然会出现错误而错误处理可以针对这些错误提前做好准备。通常出现错误时脚本会停止运行而有了错误处理脚本就可以继续运行。为此我们需要了解下面三个关键词try这是要运行的代码块可能会产生错误。except如果在try块中出现错误将执行这段代码。finally不管出现什么错误都要执行这段代码。现在我们定义一个函数“summation”将两个数字相加。该函数运行正常。defsummation(num1,num2):print(num1num2)summation(2,3)5接下来我们让用户输入其中一个数字并运行该函数。num12num2input(Enter number: )Enter number: 3summation(num1,num2)print(Thisline will not be printed because of the error)---------------------------------------------------------------------------TypeError                                Traceback (most recent call last)in----1 summation(num1,num2)2 print(This line will notbe printed because of the error)in summation(num1, num2)1 def summation(num1,num2):----2     print(num1num2)TypeError: unsupported operand type(s) for :  int  and  str“TypeError”错误出现了因为我们试图将数字和字符串相加。请注意错误出现后后面的代码便不再执行。所以我们要用到上面提到的关键词确保即使出错脚本依旧运行。try:summed2  3except:print(Summation is not ofthe same type)Summation is not of the same type可以看到try块出现错误except块的代码开始运行并打印语句。接下来加入“else”块来应对没有错误出现的情况。try:summed2 3except:print(Summation is not ofthe same type)else:print(There was no errorand result is: ,summed)There was no error and result is:  5接下来我们用另外一个例子理解。这个例子中在except块我们还标明了错误类型。如果没有标明错误类型出现一切异常都会执行except块。try:fopen( test , w )f.write(This is a testfile)except TypeError:print(There is a typeerror)except OSError:print(There is an OSerror)finally:print(This will print evenif no error)This will print even if no error现在故意创造一个错误看看except块是否与finally块共同工作吧!try:fopen( test , r )f.write(This is a testfile)except TypeError:print(There is a typeerror)except OSError:print(There is an OSerror)finally:print(This will print evenif no error)There is an OS errorThis will print even if no error【责任编辑赵宁宁 TEL(010)68476606】点赞 0
http://www.sadfv.cn/news/281327/

相关文章:

  • 成都网站搜索排名优化哪家好清新区住房和城乡建设局网站
  • wordpress区块链四川二级站seo整站优化排名
  • 常州企业网站建设dz论坛模板
  • wordpress 做外贸站中国建设网官方网站建筑工程税率
  • 怎么建立自己的网站平台扬州市工程信息网
  • 天津网站建设noajtwordpress需要什么安装环境
  • 学生组织网站建设产品推广平台有哪些
  • 网站建设管理分工的说明湘潭网站seo
  • 个人网站建设模板wordpress 内存溢出
  • 网站运营现状confluence和wordpress
  • jsp开源网站ui设计培训哪家好
  • 做内贸哪个网站找客户下载网站建设
  • 如何让新网站被收录免费app大全下载
  • 网站备案流程解答赶集直招找工作
  • 彬县网站建设茌平网站开发
  • 黄金网站软件app大全视频营销型企业网站分析与诊断
  • 网站备案流程慢建设部网站注册查询
  • 个人网站建设案例教程广州番禺核酸检测点
  • 四川专门做招聘酒的网站十五种网络营销工具
  • 微商城网站建设行情网站开发团队工作总结
  • 什么网站做问卷好龙岩到永定
  • 大连网络推广网站优化找哪家好做足彩推荐赚钱的网站
  • 033340网站建设与管理蒙文网站建设
  • 网站开发 工期安排百度扫一扫识别图片在线
  • 美食网站开发计划重庆广告牌制作
  • 整站seo排名费用价格做泵阀到哪个网站好
  • 酒店网站建设系统介绍番禺建设银行网站
  • 宁河做网站公司怎么创造自己的网站
  • 如何查看一个网站的所有二级域名网站开发需要多少钱方案
  • 佛山移动网站设计个人优秀网页设计图片