赞
踩
1.Field类简介
①Field对象指明了每个字段的元数据(任何元数据),Field对象接受的值没有任何限制
②设置Field对象的主要目就是在一个地方定义好所有的元数据
③注意,声明item的Field对象,并没有被赋值成class属性。(可通过item.fields进行访问)
④Field类仅是内置字典类(dict)的一个别名,并没有提供额外的方法和属性。被用来基于类属性的方法来支持item生命语法。
【Field类源码】
- class Field(dict):
- """Container of field metadata"""
2.dict类源码剖析
类内部方法
- class dict(object):
- """
- dict() -> 创建空字典
- dict(mapping) -> 从映射对象的键值对中初始化新字典{"key":value}
- dict(iterable) -> 从迭代器初始化字典 d[key] = value
- dict(**kwargs) -> 使用字典初始化新字典
- """
-
- # 1.清除字典内部所有内容 -> 空字典
- def clear(self):
- pass
-
- # 2.字典dict的复制
- def copy(self):
- """ dict_copy = D.copy()"""
- pass
-
- # 3.静态方法。返回一个新的字典,其中包含来自迭代器的键,以及对应的值
- @staticmethod # known case
- def fromkeys(*args, **kwargs): # real signature unknown
- pass
-
- # 4.返回指定键k的值,如果值不在字典中返回d的值
- def get(self, k, d=None): # real signature unknown; restored from __doc__
- pass
-
- # 5.以字典形式返回可遍历的(键,值)对
- def items(self): # real signature unknown; restored from __doc__
- pass
-
- # 6.以列表形式返回一个字典所有的键
- def keys(self): # real signature unknown; restored from __doc__
- pass
-
- # 7.删除字典给定键k所对应的值,返回值为被删除的值。k值必须给出。否则,返回d值。
- def pop(self, k, d=None): # real signature unknown; restored from __doc__
- pass
-
- # 8.随机返回并删除字典中的一对键和值
- def popitem(self): # real signature unknown; restored from __doc__
- pass
-
-
- # 9.和get()类似, 但如果键k不存在于字典中,将会添加键并将值设为d
- def setdefault(self, k, d=None): # real signature unknown; restored from __doc__
- pass
-
- # 10.将字典2中的键值对更新入调用字典中
- def update(self, E=None, **F): # known special case of dict.update
- """
- If E is present and has a .keys() method, then does: for k in E: D[k] = E[k]
- If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v
- In either case, this is followed by: for k in F: D[k] = F[k]
- """
- pass
-
- # 11.以字典的形式返回字典中所有的值
- def values(self): # real signature unknown; restored from __doc__
- """ D.values() -> an object providing a view on D's values """
- pass
-
- # 12.内置方法。判断键是否在字典中,在返回True,不在返回False
- def __contains__(self, *args, **kwargs): # real signature unknown
- pass
-
- # 13.删除字典中对应k键的值
- def __delitem__(self, *args, **kwargs): # real signature unknown
- """ Delete self[key]. """
- pass
-
- # 14.返回存在Value值得字典
- def __eq__(self, *args, **kwargs): # real signature unknown
- """ Return self==value. """
- pass
-
- def __getattribute__(self, *args, **kwargs): # real signature unknown
- """ Return getattr(self, name). """
- pass
-
- def __getitem__(self, y): # real signature unknown; restored from __doc__
- """ x.__getitem__(y) <==> x[y] """
- pass
-
- def __ge__(self, *args, **kwargs): # real signature unknown
- """ Return self>=value. """
- pass
-
- def __gt__(self, *args, **kwargs): # real signature unknown
- """ Return self>value. """
- pass
-
- def __init__(self, seq=None, **kwargs): # known special case of dict.__init__
- pass
-
- def __iter__(self, *args, **kwargs): # real signature unknown
- """ Implement iter(self). """
- pass
-
- def __len__(self, *args, **kwargs): # real signature unknown
- """ Return len(self). """
- pass
-
- def __le__(self, *args, **kwargs): # real signature unknown
- """ Return self<=value. """
- pass
-
- def __lt__(self, *args, **kwargs): # real signature unknown
- """ Return self<value. """
- pass
-
- @staticmethod # known case of __new__
- def __new__(*args, **kwargs): # real signature unknown
- """ Create and return a new object. See help(type) for accurate signature. """
- pass
-
- def __ne__(self, *args, **kwargs): # real signature unknown
- """ Return self!=value. """
- pass
-
- def __repr__(self, *args, **kwargs): # real signature unknown
- """ Return repr(self). """
- pass
-
- def __setitem__(self, *args, **kwargs): # real signature unknown
- """ Set self[key] to value. """
- pass
-
- def __sizeof__(self): # real signature unknown; restored from __doc__
- """ D.__sizeof__() -> size of D in memory, in bytes """
- pass
-
- __hash__ = None
- # 15.计算字典元素个数,即键的总数
- def len(*args, **kwargs): # real signature unknown
- """ Return the number of items in a container. """
- pass
-
- # 16.判断字典类型(相当于调用了type类中的__init__()初始化方法)
- def __init__(cls, what, bases=None, dict=None): # known special case of type.__init__
- """
- type(object_or_name, bases, dict)
- type(object) -> the object's type
- type(name, bases, dict) -> a new type
- # (copied from class doc)
- """
- pass
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。