python pass 的用法

    xiaoxiao2025-03-25  15

    python pass用法

    1、空语句 do nothing2、保证格式完整3、保证语义完整4、以if语句为例:

    C/C++中写法:

    if(true) ; // do nothing else {} // do nothing

    python 中写法:

    if true: pass # do nothing else: print "do something."

    测试程序:定义一个空函数

    >>> def nullfunc(): ... pass ... >>> nullfunc() >>>
    转载请注明原文地址: https://ju.6miu.com/read-1297364.html
    最新回复(0)