自学python编程笔记之python的

python中有两种注释:看以下程序示例(未使用注释):看以下程序示例(使用注释):一、注释的作用:增加程序的可读性,让开发者或后续接手程序进行维护修改的程序员提供可读性。好的程序代码通常有50%是注释!只要是被注释的代码都不会被执行!二、注释的分类:2.1单行注释:以井号“#”符号开头,其右边的都是注释,#字符开头的都是单行注释,内容不能换行,如果注释内容换行了,那么要在新的一行的,行首加一个#如:#以下代码用来打打印一个信息print(helloworld)#这里是单行注释#这是另一单行注释2.2多行注释:三个单引号或三个双引号之间的print(helloworld)print(helloworld)print(helloworld)print(helloworld)三个双引号之间的内容都是注释print(helloworld)print(helloworld)print(helloworld)三、相关错误提示代码:#coding=utf-8#这是一行注释print(helloworld)三个单引号之间的内容都是注释print(helloworld)print(helloworld)print(helloworld)三个双引号之间的内容都是注释print(helloworld)print(helloworld)print(helloworld)执行以上代码,会提示如下错误:SyntaxError:(unicodeerror)utf-8codeccantdecode这是因为文件存储的格式是ANSI,只需用notepad++打开代码文件,以UTF-8格式编码保存即可。


转载请注明:http://www.aierlanlan.com/cyrz/9232.html

  • 上一篇文章:
  •   
  • 下一篇文章: 没有了