• Python dir()/help()


    dir()

    dir()用来查询一个类或者对象所有属性。你可以尝试一下

    print dir(list)
    

    返回的结果:

    ['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__delslice__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getslice__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__', '__setslice__', '__sizeof__', '__str__', '__subclasshook__', 'append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']
    

    help()

    help()用来查询的说明文档。你可以尝试一下

    print help(list)
    

    返回的结果:

    Help on class list in module __builtin__:
    
    class list(object)
     |  list() -> new empty list
     |  list(iterable) -> new list initialized from iterable's items
     |  
     |  Methods defined here:
     |  
     |  __add__(...)
     |      x.__add__(y) <==> x+y
     |  
     |  __contains__(...)
     |      x.__contains__(y) <==> y in x
     |  
     |  __delitem__(...)
     |      x.__delitem__(y) <==> del x[y]
     |  
     |  __delslice__(...)
     |      x.__delslice__(i, j) <==> del x[i:j]
     |      
     |      Use of negative indices is not supported.
     |  
     |  __eq__(...)
     |      x.__eq__(y) <==> x==y
     |  
     |  __ge__(...)
     |      x.__ge__(y) <==> x>=y
     |  
     |  __getattribute__(...)
     |      x.__getattribute__('name') <==> x.name
     |  
    
    (数据较多未全部显示)
    
  • 相关阅读:
    2.DI依赖注入
    1.Spring框架入门案例
    5.通过参数注解多个接口参数的用法
    4.update更新和delete删除用法
    3.insert添加用法
    git基础操作
    2.mongodb可视化工具
    12.Scrapy与mongodb交互和设置中间键
    WPF 学习系列汇总
    WPF 4.0 DatePicker 快速录入
  • 原文地址:https://www.cnblogs.com/atsats/p/6103523.html
Copyright © 2020-2023  润新知