zoukankan      html  css  js  c++  java
  • python基础(一):注释

    0 ⽬标

    注释的作⽤
    注释的分类及语法
    注释的特点

    1. 注释的作⽤

    没有注释的代码
    添加注释的代码
    通过⽤⾃⼰熟悉的语⾔,在程序中对某些代码进⾏标注说明,这就是注释的作⽤,能够⼤⼤增强程序的可读性。

    2. 注释的分类及语法

    注释分为两类:单⾏注释 和 多⾏注释。
    单⾏注释
    只能注释⼀⾏内容,语法如下:
    # 注释内容
    多⾏注释
    可以注释多⾏内容,⼀般⽤在注释⼀段代码的情况, 语法如下:
    """
     第⼀⾏注释
     第⼆⾏注释
     第三⾏注释
    """
    '''
     注释1
     注释2
     注释3
    '''
    2.1 快速体验
    单⾏注释
    # 输出hello world
    print('hello world')
    print('hello Python') # 输出(简单的说明可以放到⼀⾏代码的后⾯,⼀般习惯代码后⾯添加两个空格再书写注释⽂字)
    多⾏注释
    """
     下⾯三⾏都是输出的作⽤,输出内容分别是:
     hello Python
     hello itcast
     hello itheima
    """
    print('hello Python')
    print('hello itcast')
    print('hello itheima')
    '''
     下⾯三⾏都是输出的作⽤,输出内容分别是:
     hello Python
     hello itcast
     hello itheima
    '''
    print('hello Python')
    print('hello itcast')
    print('hello itheima')
    注意:解释器不执⾏任何的注释内容。

    3 总结

    注释的作⽤
    ⽤⼈类熟悉的语⾔对代码进⾏解释说明,⽅便后期维护。
    注释的分类
    单⾏: # 注释内容 ,快捷键ctrl+/
    多⾏: """ 注释内容 """ 或 ''' 注释内容 '''
    解释器不执⾏注释内容
     
     
     
  • 相关阅读:
    C# WebApi 获取客户端ip地址
    C# 构造函数快捷键
    2 .SHELL 5~10节
    Spring项目集成apidoc生成api接口文档
    根据域名查找对应的ip及端口
    高质量SQL的30条建议
    1 .shell编程1~5
    CentOS7安装mysql8
    编译安Apache2.4.43报错checking for APR... no configure: error: APR not found. Please read the documentation.
    rm -rf * 的正确用法
  • 原文地址:https://www.cnblogs.com/qiu-hua/p/14720347.html
Copyright © 2011-2022 走看看