Python内建函数(G)
来源:互联网 发布:手机淘宝怎么选择客服 编辑:程序博客网 时间:2024/06/07 13:11
- getattr(object, name [, defalut])
说明:获取对象object名为name的特性。如果object不包含名为name的特性,将会抛出AttributeError异常;如果不包含名为name的特性且提供default参数,将返回default。
参数object:对象。
参数name:对象的特性名。
参数default:缺省返回值。
示例:
>>> append = getattr(list, 'append')>>> append <method 'append' of 'list' objects>>>> mylist = [3, 4, 5]>>> mylist[3, 4, 5]>>> append(mylist, 6)>>> mylist[3, 4, 5, 6]>>> method = getattr(list, 'add')Traceback (most recent call last): File "<stdin>", line 1, in <module>AttributeError: type object 'list' has no attribute 'add'>>> method = getattr(list, 'add', 'NoMethod')>>> method'NoMethod'
- globals()
说明:返回一个描述当前全局符号表的字典。
示例:
>>> globals(){'__builtins__': <module '__builtin__' (built-in)>, '__name__': '__main__', '__doc__': None, '__package__': None}
- Python内建函数(G)
- Python 内建函数
- Python内建函数
- Python内建函数
- Python 内建函数
- python 内建函数
- python内建函数
- Python内建函数
- Python 内建函数
- Python--内建函数
- python-内建函数
- python 内建函数
- Python--内建函数
- python内建函数
- python内建函数
- python 内建函数
- python内建函数
- Python内建函数(A)
- Python内建函数(F)
- 大数,高精度计算---百位大数
- xcode插件
- 实时错误'91'----对象变量或wih块变量未设置
- NFC高级
- Python内建函数(G)
- windows adb
- Python内建函数(H)
- 网站反爬虫
- MPEG2-TS音视频同步原理
- android之RelativeLayout(相对布局)
- java 权限 部分截图
- hdu 4635 非强连通图最大边数
- FFmpeg对mpeg2-TS解析的最详细分析