十八、copyright方法、credits方法
此二种方法不做多解释, 直接上例子:
>>> credits
Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands
for supporting Python development. See www.python.org for more information.>>> copyright Copyright (c) 2001-2014 Python Software Foundation. All Rights Reserved. Copyright (c) 2000 BeOpen.com. All Rights Reserved. Copyright (c) 1995-2001 Corporation for National Research Initiatives. All Rights Reserved. Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam. All Rights Reserved.
十九、delattr方法
1、定义:
delattr(...)
delattr(object, name)
Delete a named attribute on an object; delattr(x, 'y') is equivalent to
``del x.y''.2、解释:删除一个对象已定义的属性,相当于 del object.name
3、举例:
>>> dir(datetime) ['MAXYEAR', 'MINYEAR', '__doc__', '__name__', '__package__', 'date', 'datetime', 'datetime_CAPI', 'time', 'timedelta', 'tzinfo'] >>> delattr(datetime, 'time') >>> dir(datetime) ['MAXYEAR', 'MINYEAR', '__doc__', '__name__', '__package__', 'date', 'datetime', 'datetime_CAPI', 'timedelta', 'tzinfo']
二十、dict类
1、定义:
class dict(object)
| dict() -> new empty dictionary
| dict(mapping) -> new dictionary initialized from a mapping object's
| (key, value) pairs
| dict(iterable) -> new dictionary initialized as if via:
| d = {}
| for k, v in iterable:
| d[k] = v
| dict(**kwargs) -> new dictionary initialized with the name=value pairs
| in the keyword argument list. For example: dict(one=1, two=2)2、解释:用于生成一个新字典,生成方式见举例。
3、举例:
>>> dict()
{}
>>> dict([('a',4),('b',5)])
{'a': 4, 'b': 5}
>>> dict(a='4',b=5)
{'a': '4', 'b': 5}
二十一、dir方法
此方法前面的博客中已介绍过, 可点击http://www.aoyanming.com/blog/display/6查看
Copyright © 2021.aoyanming个人博客站
发表评论