Collcetions系列

一、count计数器

Count主要是提供统计功能,用于统计字符串里某个字符出现的次数。

使用count前需要导入collcetions模块。

>>>import collections
>>>obj = collections.Counter(‘adkloalnflasmfa‘)
>>>print(obj)
Counter({‘a‘: 4, ‘l‘: 3, ‘f‘: 2, ‘k‘: 1, ‘d‘: 1, ‘m‘: 1, ‘s‘: 1, ‘o‘: 1, ‘n‘: 1})

遍历counter里面的内容

for item in obj.elements():
    print(item)

更新

>>>obj = collections.Counter([‘11‘,‘22‘,‘22‘,‘33‘])
>>>print(obj)
Counter({‘22‘: 2, ‘11‘: 1, ‘33‘: 1})
>>>obj.update([‘eric‘,‘11‘,‘11‘])
>>>print(obj)
Counter({‘11‘: 3, ‘22‘: 2, ‘eric‘: 1, ‘33‘: 1})

内置函数

def __init__(*args, **kwds):
        ‘‘‘Create a new, empty Counter object.  And if given, count elements
        from an input iterable.  Or, initialize the count from another mapping
        of elements to their counts.

        >>> c = Counter()                           # a new, empty counter
        >>> c = Counter(‘gallahad‘)                 # a new counter from an iterable
        >>> c = Counter({‘a‘: 4, ‘b‘: 2})           # a new counter from a mapping
        >>> c = Counter(a=4, b=2)                   # a new counter from keyword args

        ‘‘‘
        if not args:
            raise TypeError("descriptor ‘__init__‘ of ‘Counter‘ object "
                            "needs an argument")
        self, *args = args
        if len(args) > 1:
            raise TypeError(‘expected at most 1 arguments, got %d‘ % len(args))
        super(Counter, self).__init__()
        self.update(*args, **kwds)

    def __missing__(self, key):
        ‘The count of elements not in the Counter is zero.‘
        # Needed so that self[missing_item] does not raise KeyError
        return 0

    def most_common(self, n=None):
        ‘‘‘List the n most common elements and their counts from the most
        common to the least.  If n is None, then list all element counts.

        >>> Counter(‘abcdeabcdabcaba‘).most_common(3)
        [(‘a‘, 5), (‘b‘, 4), (‘c‘, 3)]

        ‘‘‘
        # Emulate Bag.sortedByCount from Smalltalk
        if n is None:
            return sorted(self.items(), key=_itemgetter(1), reverse=True)
        return _heapq.nlargest(n, self.items(), key=_itemgetter(1))

    def elements(self):
        ‘‘‘Iterator over elements repeating each as many times as its count.

        >>> c = Counter(‘ABCABC‘)
        >>> sorted(c.elements())
        [‘A‘, ‘A‘, ‘B‘, ‘B‘, ‘C‘, ‘C‘]

        # Knuth‘s example for prime factors of 1836:  2**2 * 3**3 * 17**1
        >>> prime_factors = Counter({2: 2, 3: 3, 17: 1})
        >>> product = 1
        >>> for factor in prime_factors.elements():     # loop over factors
        ...     product *= factor                       # and multiply them
        >>> product
        1836

        Note, if an element‘s count has been set to zero or is a negative
        number, elements() will ignore it.

        ‘‘‘
        # Emulate Bag.do from Smalltalk and Multiset.begin from C++.
        return _chain.from_iterable(_starmap(_repeat, self.items()))

    # Override dict methods where necessary

    @classmethod
    def fromkeys(cls, iterable, v=None):
        # There is no equivalent method for counters because setting v=1
        # means that no element can have a count greater than one.
        raise NotImplementedError(
            ‘Counter.fromkeys() is undefined.  Use Counter(iterable) instead.‘)

    def update(*args, **kwds):
        ‘‘‘Like dict.update() but add counts instead of replacing them.

        Source can be an iterable, a dictionary, or another Counter instance.

        >>> c = Counter(‘which‘)
        >>> c.update(‘witch‘)           # add elements from another iterable
        >>> d = Counter(‘watch‘)
        >>> c.update(d)                 # add elements from another counter
        >>> c[‘h‘]                      # four ‘h‘ in which, witch, and watch
        4

        ‘‘‘
        # The regular dict.update() operation makes no sense here because the
        # replace behavior results in the some of original untouched counts
        # being mixed-in with all of the other counts for a mismash that
        # doesn‘t have a straight-forward interpretation in most counting
        # contexts.  Instead, we implement straight-addition.  Both the inputs
        # and outputs are allowed to contain zero and negative counts.

        if not args:
            raise TypeError("descriptor ‘update‘ of ‘Counter‘ object "
                            "needs an argument")
        self, *args = args
        if len(args) > 1:
            raise TypeError(‘expected at most 1 arguments, got %d‘ % len(args))
        iterable = args[0] if args else None
        if iterable is not None:
            if isinstance(iterable, Mapping):
                if self:
                    self_get = self.get
                    for elem, count in iterable.items():
                        self[elem] = count + self_get(elem, 0)
                else:
                    super(Counter, self).update(iterable) # fast path when counter is empty
            else:
                _count_elements(self, iterable)
        if kwds:
            self.update(kwds)

    def subtract(*args, **kwds):
        ‘‘‘Like dict.update() but subtracts counts instead of replacing them.
        Counts can be reduced below zero.  Both the inputs and outputs are
        allowed to contain zero and negative counts.

        Source can be an iterable, a dictionary, or another Counter instance.

        >>> c = Counter(‘which‘)
        >>> c.subtract(‘witch‘)             # subtract elements from another iterable
        >>> c.subtract(Counter(‘watch‘))    # subtract elements from another counter
        >>> c[‘h‘]                          # 2 in which, minus 1 in witch, minus 1 in watch
        0
        >>> c[‘w‘]                          # 1 in which, minus 1 in witch, minus 1 in watch
        -1

        ‘‘‘
        if not args:
            raise TypeError("descriptor ‘subtract‘ of ‘Counter‘ object "
                            "needs an argument")
        self, *args = args
        if len(args) > 1:
            raise TypeError(‘expected at most 1 arguments, got %d‘ % len(args))
        iterable = args[0] if args else None
        if iterable is not None:
            self_get = self.get
            if isinstance(iterable, Mapping):
                for elem, count in iterable.items():
                    self[elem] = self_get(elem, 0) - count
            else:
                for elem in iterable:
                    self[elem] = self_get(elem, 0) - 1
        if kwds:
            self.subtract(kwds)

    def copy(self):
        ‘Return a shallow copy.‘
        return self.__class__(self)

    def __reduce__(self):
        return self.__class__, (dict(self),)

    def __delitem__(self, elem):
        ‘Like dict.__delitem__() but does not raise KeyError for missing values.‘
        if elem in self:
            super().__delitem__(elem)

    def __repr__(self):
        if not self:
            return ‘%s()‘ % self.__class__.__name__
        try:
            items = ‘, ‘.join(map(‘%r: %r‘.__mod__, self.most_common()))
            return ‘%s({%s})‘ % (self.__class__.__name__, items)
        except TypeError:
            # handle case where values are not orderable
            return ‘{0}({1!r})‘.format(self.__class__.__name__, dict(self))

    # Multiset-style mathematical operations discussed in:
    #       Knuth TAOCP Volume II section 4.6.3 exercise 19
    #       and at http://en.wikipedia.org/wiki/Multiset
    #
    # Outputs guaranteed to only include positive counts.
    #
    # To strip negative and zero counts, add-in an empty counter:
    #       c += Counter()

    def __add__(self, other):
        ‘‘‘Add counts from two counters.

        >>> Counter(‘abbb‘) + Counter(‘bcc‘)
        Counter({‘b‘: 4, ‘c‘: 2, ‘a‘: 1})

        ‘‘‘
        if not isinstance(other, Counter):
            return NotImplemented
        result = Counter()
        for elem, count in self.items():
            newcount = count + other[elem]
            if newcount > 0:
                result[elem] = newcount
        for elem, count in other.items():
            if elem not in self and count > 0:
                result[elem] = count
        return result

    def __sub__(self, other):
        ‘‘‘ Subtract count, but keep only results with positive counts.

        >>> Counter(‘abbbc‘) - Counter(‘bccd‘)
        Counter({‘b‘: 2, ‘a‘: 1})

        ‘‘‘
        if not isinstance(other, Counter):
            return NotImplemented
        result = Counter()
        for elem, count in self.items():
            newcount = count - other[elem]
            if newcount > 0:
                result[elem] = newcount
        for elem, count in other.items():
            if elem not in self and count < 0:
                result[elem] = 0 - count
        return result

    def __or__(self, other):
        ‘‘‘Union is the maximum of value in either of the input counters.

        >>> Counter(‘abbb‘) | Counter(‘bcc‘)
        Counter({‘b‘: 3, ‘c‘: 2, ‘a‘: 1})

        ‘‘‘
        if not isinstance(other, Counter):
            return NotImplemented
        result = Counter()
        for elem, count in self.items():
            other_count = other[elem]
            newcount = other_count if count < other_count else count
            if newcount > 0:
                result[elem] = newcount
        for elem, count in other.items():
            if elem not in self and count > 0:
                result[elem] = count
        return result

    def __and__(self, other):
        ‘‘‘ Intersection is the minimum of corresponding counts.

        >>> Counter(‘abbb‘) & Counter(‘bcc‘)
        Counter({‘b‘: 1})

        ‘‘‘
        if not isinstance(other, Counter):
            return NotImplemented
        result = Counter()
        for elem, count in self.items():
            other_count = other[elem]
            newcount = count if count < other_count else other_count
            if newcount > 0:
                result[elem] = newcount
        return result

    def __pos__(self):
        ‘Adds an empty counter, effectively stripping negative and zero counts‘
        return self + Counter()

    def __neg__(self):
        ‘‘‘Subtracts from an empty counter.  Strips positive and zero counts,
        and flips the sign on negative counts.

        ‘‘‘
        return Counter() - self

    def _keep_positive(self):
        ‘‘‘Internal method to strip elements with a negative or zero count‘‘‘
        nonpositive = [elem for elem, count in self.items() if not count > 0]
        for elem in nonpositive:
            del self[elem]
        return self

    def __iadd__(self, other):
        ‘‘‘Inplace add from another counter, keeping only positive counts.

        >>> c = Counter(‘abbb‘)
        >>> c += Counter(‘bcc‘)
        >>> c
        Counter({‘b‘: 4, ‘c‘: 2, ‘a‘: 1})

        ‘‘‘
        for elem, count in other.items():
            self[elem] += count
        return self._keep_positive()

    def __isub__(self, other):
        ‘‘‘Inplace subtract counter, but keep only results with positive counts.

        >>> c = Counter(‘abbbc‘)
        >>> c -= Counter(‘bccd‘)
        >>> c
        Counter({‘b‘: 2, ‘a‘: 1})

        ‘‘‘
        for elem, count in other.items():
            self[elem] -= count
        return self._keep_positive()

    def __ior__(self, other):
        ‘‘‘Inplace union is the maximum of value from either counter.

        >>> c = Counter(‘abbb‘)
        >>> c |= Counter(‘bcc‘)
        >>> c
        Counter({‘b‘: 3, ‘c‘: 2, ‘a‘: 1})

        ‘‘‘
        for elem, other_count in other.items():
            count = self[elem]
            if other_count > count:
                self[elem] = other_count
        return self._keep_positive()

    def __iand__(self, other):
        ‘‘‘Inplace intersection is the minimum of corresponding counts.

        >>> c = Counter(‘abbb‘)
        >>> c &= Counter(‘bcc‘)
        >>> c
        Counter({‘b‘: 1})

        ‘‘‘
        for elem, count in self.items():
            other_count = other[elem]
            if other_count < count:
                self[elem] = other_count
        return self._keep_positive()

Counter

二、有序字典

创建字典

>>>dic = collections.OrderedDict()
>>>dic[‘k1‘] = ‘v1‘
>>>dic[‘k2‘] = ‘v2‘
>>>dic[‘k3‘] = ‘v3‘

内置函数

def __init__(*args, **kwds):
        ‘‘‘Initialize an ordered dictionary.  The signature is the same as
        regular dictionaries, but keyword arguments are not recommended because
        their insertion order is arbitrary.

        ‘‘‘
        if not args:
            raise TypeError("descriptor ‘__init__‘ of ‘OrderedDict‘ object "
                            "needs an argument")
        self, *args = args
        if len(args) > 1:
            raise TypeError(‘expected at most 1 arguments, got %d‘ % len(args))
        try:
            self.__root
        except AttributeError:
            self.__hardroot = _Link()
            self.__root = root = _proxy(self.__hardroot)
            root.prev = root.next = root
            self.__map = {}
        self.__update(*args, **kwds)

    def __setitem__(self, key, value,
                    dict_setitem=dict.__setitem__, proxy=_proxy, Link=_Link):
        ‘od.__setitem__(i, y) <==> od[i]=y‘
        # Setting a new item creates a new link at the end of the linked list,
        # and the inherited dictionary is updated with the new key/value pair.
        if key not in self:
            self.__map[key] = link = Link()
            root = self.__root
            last = root.prev
            link.prev, link.next, link.key = last, root, key
            last.next = link
            root.prev = proxy(link)
        dict_setitem(self, key, value)

    def __delitem__(self, key, dict_delitem=dict.__delitem__):
        ‘od.__delitem__(y) <==> del od[y]‘
        # Deleting an existing item uses self.__map to find the link which gets
        # removed by updating the links in the predecessor and successor nodes.
        dict_delitem(self, key)
        link = self.__map.pop(key)
        link_prev = link.prev
        link_next = link.next
        link_prev.next = link_next
        link_next.prev = link_prev

    def __iter__(self):
        ‘od.__iter__() <==> iter(od)‘
        # Traverse the linked list in order.
        root = self.__root
        curr = root.next
        while curr is not root:
            yield curr.key
            curr = curr.next

    def __reversed__(self):
        ‘od.__reversed__() <==> reversed(od)‘
        # Traverse the linked list in reverse order.
        root = self.__root
        curr = root.prev
        while curr is not root:
            yield curr.key
            curr = curr.prev

    def clear(self):
        ‘od.clear() -> None.  Remove all items from od.‘
        root = self.__root
        root.prev = root.next = root
        self.__map.clear()
        dict.clear(self)

    def popitem(self, last=True):
        ‘‘‘od.popitem() -> (k, v), return and remove a (key, value) pair.
        Pairs are returned in LIFO order if last is true or FIFO order if false.

        ‘‘‘
        if not self:
            raise KeyError(‘dictionary is empty‘)
        root = self.__root
        if last:
            link = root.prev
            link_prev = link.prev
            link_prev.next = root
            root.prev = link_prev
        else:
            link = root.next
            link_next = link.next
            root.next = link_next
            link_next.prev = root
        key = link.key
        del self.__map[key]
        value = dict.pop(self, key)
        return key, value

    def move_to_end(self, key, last=True):
        ‘‘‘Move an existing element to the end (or beginning if last==False).

        Raises KeyError if the element does not exist.
        When last=True, acts like a fast version of self[key]=self.pop(key).

        ‘‘‘
        link = self.__map[key]
        link_prev = link.prev
        link_next = link.next
        link_prev.next = link_next
        link_next.prev = link_prev
        root = self.__root
        if last:
            last = root.prev
            link.prev = last
            link.next = root
            last.next = root.prev = link
        else:
            first = root.next
            link.prev = root
            link.next = first
            root.next = first.prev = link

    def __sizeof__(self):
        sizeof = _sys.getsizeof
        n = len(self) + 1                       # number of links including root
        size = sizeof(self.__dict__)            # instance dictionary
        size += sizeof(self.__map) * 2          # internal dict and inherited dict
        size += sizeof(self.__hardroot) * n     # link objects
        size += sizeof(self.__root) * n         # proxy objects
        return size

    update = __update = MutableMapping.update
    keys = MutableMapping.keys
    values = MutableMapping.values
    items = MutableMapping.items
    __ne__ = MutableMapping.__ne__

    __marker = object()

    def pop(self, key, default=__marker):
        ‘‘‘od.pop(k[,d]) -> v, remove specified key and return the corresponding
        value.  If key is not found, d is returned if given, otherwise KeyError
        is raised.

        ‘‘‘
        if key in self:
            result = self[key]
            del self[key]
            return result
        if default is self.__marker:
            raise KeyError(key)
        return default

    def setdefault(self, key, default=None):
        ‘od.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in od‘
        if key in self:
            return self[key]
        self[key] = default
        return default

    @_recursive_repr()
    def __repr__(self):
        ‘od.__repr__() <==> repr(od)‘
        if not self:
            return ‘%s()‘ % (self.__class__.__name__,)
        return ‘%s(%r)‘ % (self.__class__.__name__, list(self.items()))

    def __reduce__(self):
        ‘Return state information for pickling‘
        inst_dict = vars(self).copy()
        for k in vars(OrderedDict()):
            inst_dict.pop(k, None)
        return self.__class__, (), inst_dict or None, None, iter(self.items())

    def copy(self):
        ‘od.copy() -> a shallow copy of od‘
        return self.__class__(self)

    @classmethod
    def fromkeys(cls, iterable, value=None):
        ‘‘‘OD.fromkeys(S[, v]) -> New ordered dictionary with keys from S.
        If not specified, the value defaults to None.

        ‘‘‘
        self = cls()
        for key in iterable:
            self[key] = value
        return self

    def __eq__(self, other):
        ‘‘‘od.__eq__(y) <==> od==y.  Comparison to another OD is order-sensitive
        while comparison to a regular mapping is order-insensitive.

        ‘‘‘
        if isinstance(other, OrderedDict):
            return dict.__eq__(self, other) and all(map(_eq, self, other))
        return dict.__eq__(self, other)

OrderedDict

三、默认字典

创建默认字典

>>>dic = collections.defaultdict(list)
>>>dic[‘k1‘].append(‘alex‘)
>>>print(dic)
defaultdict(<class ‘list‘>, {‘k1‘: [‘alex‘]})

方法与内置函数

def copy(self): # real signature unknown; restored from __doc__
        """ D.copy() -> a shallow copy of D. """
        pass

    def __copy__(self, *args, **kwargs): # real signature unknown
        """ D.copy() -> a shallow copy of D. """
        pass

    def __getattribute__(self, *args, **kwargs): # real signature unknown
        """ Return getattr(self, name). """
        pass

    def __init__(self, default_factory=None, **kwargs): # known case of _collections.defaultdict.__init__
        """
        defaultdict(default_factory[, ...]) --> dict with default factory

        The default factory is called without arguments to produce
        a new value when a key is not present, in __getitem__ only.
        A defaultdict compares equal to a dict with the same items.
        All remaining arguments are treated the same as if they were
        passed to the dict constructor, including keyword arguments.

        # (copied from class doc)
        """
        pass

    def __missing__(self, key): # real signature unknown; restored from __doc__
        """
        __missing__(key) # Called by __getitem__ for missing key; pseudo-code:
          if self.default_factory is None: raise KeyError((key,))
          self[key] = value = self.default_factory()
          return value
        """
        pass

    def __reduce__(self, *args, **kwargs): # real signature unknown
        """ Return state information for pickling. """
        pass

    def __repr__(self, *args, **kwargs): # real signature unknown
        """ Return repr(self). """
        pass

    default_factory = property(lambda self: object(), lambda self, v: None, lambda self: None)  # default
    """Factory for default value called by __missing__()."""

方法%内置函数

四、可命名元组

#创建类
MytupleClass = collections.namedtuple(‘MytupleClass‘,[‘x‘,‘y‘,‘z‘])
#创建对象
obj = MytupleClass(11,22,33)
print(obj.x)
print(obj.y)
print(obj.z)
11
22
33
时间: 2024-10-28 10:21:14

Collcetions系列的相关文章

【Windows10&nbsp;IoT开发系列】配置篇

原文:[Windows10 IoT开发系列]配置篇 Windows10 For IoT是Windows 10家族的一个新星,其针对不同平台拥有不同的版本.而其最重要的一个版本是运行在Raspberry Pi.MinnowBoard和Galileo平台上的核心版.本文重点针对Raspberry Pi平台的Windwos10 IoT配置做介绍. Windows 10 IoT Editions ​一:设置你的电脑. 注:​开发Windows10 IoT的电脑需要Visual Studio 2015.

【Windows10&nbsp;IoT开发系列】PowerShell的相关配置

原文:[Windows10 IoT开发系列]PowerShell的相关配置 可使用 Windows PowerShell 远程配置和管理任何 Windows 10 IoT 核心版设备.PowerShell 是基于任务的命令行 Shell 和脚本语言,专为进行系统管理而设计. 1.​启动 PowerShell (PS) 会话 注:若要使用装有Windows10 IoT Core设备启动PS会话,首先需要在主机电脑与设备之间创建信任关系. ​启动 Windows IoT 核心版设备后,与该设备相连的

【Windows10&nbsp;IoT开发系列】API&nbsp;移植工具

原文:[Windows10 IoT开发系列]API 移植工具 Windows 10 IoT Core 中是否提供你的当前 Win32 应用程序或库所依赖的 API? 如果不提供,是否存在可使用的等效 API? 此工具可以为你回答这些问题,并协助你将你的当前 Win32 应用程序和库迁移到 Windows IoT Core. Windows 10 IoT 核心版 API 移植工具可在 ms-iot/iot-utilities github 存储库中找到.下载存储库 zip 并将 IoTAPIPor

【Windows10&nbsp;IoT开发系列】“Hello,World!”指导

原文:[Windows10 IoT开发系列]"Hello,World!"指导 本文主要是介绍使用C#来开发一个可以运行在Raspberry Pi2上的一个基本项目. ​1.在启动Visual Studio 2015后,选择"文件"→"新建项目". ​在打开的"新建项目"对话框中,选择"通用". ​选择第一个项目"空白应用(通用Windows)" 新建项目 ​注:如果这是你创建的第一个项

【Windows10&nbsp;IoT开发系列】开发人员模式设置

原文:[Windows10 IoT开发系列]开发人员模式设置  声明:本文转自微软Windows 开发人员中心(https://msdn.microsoft.com/library/windows/apps/xaml/dn706236.aspx),在此基础上进行删减和修改. ​对于要用于开发.安装或测试应用的设备,不再需要开发人员许可证.你只需从设备的设置中为这些任务启用设备一次.(仅限于运行Windows 10系统的设备) 使用开发人员功能 ​使用 Microsoft Visual Stud

【Windows10&nbsp;IoT开发系列】Powershell命令行实用程序

原文:[Windows10 IoT开发系列]Powershell命令行实用程序 更新帐户密码: 强烈建议你更新默认的管理员帐户密码.若要更新帐户密码,你可以发出以下命令: net user Administrator [new password]​ (其中 [new password] 表示你选择的强密码). 创建本地用户帐户: 如果你想要授予其他人访问你的 Windows IoT Core 设备的权限,你可以通过在 net user [username] [password] /add​ 中键

时序图与状态图(Rose) - Windows XP经典软件系列

最近开始了自己高级数据结构之旅,在这次旅行中,我将持续把一些高级的数据结构从理论到编码都过一遍,同时通过博客形式分享出来,希望大家指出不足之处! 二叉排序树是一种动态排序的数据结构,支持插入.删除.查找等操作,且平均时间复杂度为O(log(N)),但是普通二叉排序树不能保证树退化为一颗分支的情况,此时最坏情况下的时间复杂度为O(N).此时,平衡二叉树的产生了.平衡二叉树是一种动态调整平衡的数据结构,但理想的平衡二叉树很难,于是人们使用AVL.红黑树.Treap.伸展树等来替代平衡二叉树,这些数据

类图(Rose) - Windows XP经典软件系列

最近开始了自己高级数据结构之旅,在这次旅行中,我将持续把一些高级的数据结构从理论到编码都过一遍,同时通过博客形式分享出来,希望大家指出不足之处! 二叉排序树是一种动态排序的数据结构,支持插入.删除.查找等操作,且平均时间复杂度为O(log(N)),但是普通二叉排序树不能保证树退化为一颗分支的情况,此时最坏情况下的时间复杂度为O(N).此时,平衡二叉树的产生了.平衡二叉树是一种动态调整平衡的数据结构,但理想的平衡二叉树很难,于是人们使用AVL.红黑树.Treap.伸展树等来替代平衡二叉树,这些数据

[Nhibernate]Nhibernate系列之体系结构

引言 在项目中也有用到过nhibernate但对nhibernate的认识,也存留在会用的阶段,从没深入的学习过,决定对nhibernate做一个系统的学习. ORM 对象-关系映射(OBJECT/RELATION MAPPING,简称ORM),是随着面向对象的软件开发方法发展而产生的.面向对象的开发方法是当今企业级应用开发环境中的主流开发方法,关系数据库是企业级应用环境中永久存放数据的主流数据存储系统.对象和关系数据是业务实体的两种表现形式,业务实体在内存中表现为对象,在数据库中表现为关系数据