zoukankan      html  css  js  c++  java
  • Python动态特性


    动态特性:
    不需要输个数
    import inspect
    import dis

    def howmany():
    f=inspect.currentframe()
    f=f.f_back
    dis.disassemble(f.f_code,f.f_lasti)
    n=ord(f.f_code.co_code[f.f_lasti+4])
    print n
    return range(n)

    if __name__=='__main__':
    x,y=howmany()
    print x,y


    >>> import inspect
    >>> def howmany():
    f=inspect.currentframe().f_back
    return range(ord(f.f_code.co_code[f.f_lasti+4]))

    >>> x,y=howmany()
    >>> x
    0
    >>> y
    1
    >>> x,y,z=howmany()
    >>> x
    0
    >>> y
    1
    >>> z
    2
    >>>

    http://hi.baidu.com/mirguest/blog/item/7e21d0974a5e0c1b7bf48006.html
    http://club.topsage.com/thread-252948-1-1.html

  • 相关阅读:
    Nginx
    Nginx & AWStats 安装、配置、使用
    Nginx
    linux
    工作中的 Vim 和 git
    后端
    django
    django
    awk流程控制
    linux系统内置函数
  • 原文地址:https://www.cnblogs.com/moonflow/p/2388851.html
Copyright © 2011-2022 走看看