码迷,mamicode.com
首页 > 其他好文 > 详细

list(列表)功能详解

时间:2016-01-14 13:59:14      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:

class list(object):
    """
    list() -> new empty list
    list(iterable) -> new list initialized from iterable‘s items
    """
    def append(self, p_object): # real signature unknown; restored from __doc__
        """ L.append(object) -- append object to end """
        pass
        a=[‘abs‘,‘ads‘,‘aps‘,]
        b=[‘abs‘,‘ads‘,‘aps‘,]
        print(list.append(a,‘afs‘))
        print (a)
        [‘abs‘, ‘ads‘, ‘aps‘, ‘afs‘] 向列表末尾增加这个字段
    
    def count(self, value): # real signature unknown; restored from __doc__
        """ L.count(value) -> integer -- return number of occurrences of value """
        return 0
        b=[‘abs‘,‘ads‘,‘aps‘,]
        print(list.count(b,‘abs‘))
        1 统计出现列表中字段的总数
        
    def extend(self, iterable): # real signature unknown; restored from __doc__
        """ L.extend(iterable) -- extend list by appending elements from the iterable """
        pass
        a=[‘abs‘,‘ads‘,‘aps‘,]
        b=[‘abs‘,‘ads‘,‘aps‘,]
        print(list.extend(a,b))
        print(a)
        [‘abs‘, ‘ads‘, ‘aps‘, ‘abs‘, ‘ads‘, ‘aps‘]
        扩展列表
        
    def index(self, value, start=None, stop=None): # real signature unknown; restored from __doc__
        """
        L.index(value, [start, [stop]]) -> integer -- return first index of value.
        Raises ValueError if the value is not present.
        """
        return 0
        查看列表索引

    def insert(self, index, p_object): # real signature unknown; restored from __doc__
        """ L.insert(index, object) -- insert object before index """
        pass
        向列表指定索引位置插入字段

    def pop(self, index=None): # real signature unknown; restored from __doc__
        """
        L.pop([index]) -> item -- remove and return item at index (default last).
        Raises IndexError if list is empty or index is out of range.
        """
        pass
        删除一个索引字段
        
    def remove(self, value): # real signature unknown; restored from __doc__
        """
        L.remove(value) -- remove first occurrence of value.
        Raises ValueError if the value is not present.
        """
        pass
        移除一个字段

    def reverse(self): # real signature unknown; restored from __doc__
        """ L.reverse() -- reverse *IN PLACE* """
        pass
        反转排序

    def sort(self, cmp=None, key=None, reverse=False): # real signature unknown; restored from __doc__
        """
        L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*;
        cmp(x, y) -> -1, 0, 1
        """
        pass
        排序

    def __add__(self, y): # real signature unknown; restored from __doc__
        """ x.__add__(y) <==> x+y """
        pass
        添加
        
    def __contains__(self, y): # real signature unknown; restored from __doc__
        """ x.__contains__(y) <==> y in x """
        pass
        是否在列表中
        
    def __delitem__(self, y): # real signature unknown; restored from __doc__
        """ x.__delitem__(y) <==> del x[y] """
        pass
        b=[‘abs‘,‘ads‘,‘aps‘,]
        print(list.__delitem__(b,0))
        print(b) [‘ads‘, ‘aps‘] 将指定索引字段切除
        
    ‘‘‘
    def __delslice__(self, i, j): # real signature unknown; restored from __doc__
        """
        x.__delslice__(i, j) <==> del x[i:j]
                   
                   Use of negative indices is not supported.
        """
        pass
    ‘‘‘    

    def __eq__(self, y): # real signature unknown; restored from __doc__
        """ x.__eq__(y) <==> x==y """
        pass
        a=[‘abs‘,‘ads‘,‘aps‘,]
        b=[‘abs‘,‘ads‘,‘aps‘,]
        print(list.__eq__(a,b))
        True
        两个列表是否相同
    def __getattribute__(self, name): # real signature unknown; restored from __doc__
        """ x.__getattribute__(‘name‘) <==> x.name """
        pass
        恢复结构
        
    def __getitem__(self, y): # real signature unknown; restored from __doc__
        """ x.__getitem__(y) <==> x[y] """
        pass
        b=[‘abs‘,‘ads‘,‘aps‘,]
        print(list.__getitem__(b,1,))
        ads 查询列表中索引位置的字段
    ‘‘‘    
    def __getslice__(self, i, j): # real signature unknown; restored from __doc__
        """
        x.__getslice__(i, j) <==> x[i:j]
                   
                   Use of negative indices is not supported.
        """
        pass
    ‘‘‘    
        
    def __ge__(self, y): # real signature unknown; restored from __doc__
        """ x.__ge__(y) <==> x>=y """
        pass
        a=[‘abs‘,‘ads‘,‘aps‘,]
        b=[‘abs‘,‘ads‘,‘aps‘,]
        print(list.__ge__(a,b))
        true
        大于等于
    
    def    __gt__(self, y): # real signature unknown; restored from __doc__
        """ x.__gt__(y) <==> x>y """
        pass
        大于
    def __iadd__(self, y): # real signature unknown; restored from __doc__
        """ x.__iadd__(y) <==> x+=y """
        pass
        a=[‘abs‘,‘ads‘,‘aps‘,]
        b=[‘abs‘,‘ads‘,‘aps‘,]
        print(list.__iadd__(b,a))
        [‘abs‘, ‘ads‘, ‘aps‘, ‘abs‘, ‘ads‘, ‘aps‘]进行相加
        
    def __imul__(self, y): # real signature unknown; restored from __doc__
        """ x.__imul__(y) <==> x*=y """
        pass
        生成列表中字段*倍数
        
    def __init__(self, seq=()): # known special case of list.__init__
        """
        list() -> new empty list
        list(iterable) -> new list initialized from iterable‘s items
        # (copied from class doc)
        """
        pass
        print(list.__init__(a,‘ags‘,))
        print(a) 生成新的列表 [‘a‘, ‘g‘, ‘s‘]

    def __iter__(self): # real signature unknown; restored from __doc__
        """ x.__iter__() <==> iter(x) """
        pass
        b=[‘abs‘,‘ads‘,‘aps‘,]
        print(list.__iter__(b))
        <list_iterator object at 0x000000000118DD30>显示16进制
    def __len__(self): # real signature unknown; restored from __doc__
        """ x.__len__() <==> len(x) """
        pass
        print(list.__len__(b))
        3 显示长度
        
    def __le__(self, y): # real signature unknown; restored from __doc__
        """ x.__le__(y) <==> x<=y """
       小于等于
    def __lt__(self, y): # real signature unknown; restored from __doc__
        """ x.__lt__(y) <==> x<y """
        pass
        小于
    def __mul__(self, n): # real signature unknown; restored from __doc__
        """ x.__mul__(n) <==> x*n """
        pass
        b=[‘abs‘,‘ads‘,‘aps‘,]
        print(list.__mul__(b,2))
        print(b) [‘abs‘, ‘ads‘, ‘aps‘, ‘abs‘, ‘ads‘, ‘aps‘]乘倍数
        
    @staticmethod # known case of __new__
    def __new__(S, *more): # real signature unknown; restored from __doc__
        """ T.__new__(S, ...) -> a new object with type S, a subtype of T """
        pass

    def __ne__(self, y): # real signature unknown; restored from __doc__
        """ x.__ne__(y) <==> x!=y """
        pass
        是否不相等

    def __repr__(self): # real signature unknown; restored from __doc__
        """ x.__repr__() <==> repr(x) """
        pass
        恢复结构

    def __reversed__(self): # real signature unknown; restored from __doc__
        """ L.__reversed__() -- return a reverse iterator over the list """
        pass
        显示16进制

    def __rmul__(self, n): # real signature unknown; restored from __doc__
        """ x.__rmul__(n) <==> n*x """
        pass
        从左到右倍数乘列表字段

    def __setitem__(self, i, y): # real signature unknown; restored from __doc__
        """ x.__setitem__(i, y) <==> x[i]=y """
        pass
        
‘‘‘
    def __setslice__(self, i, j, y): # real signature unknown; restored from __doc__
        """
        x.__setslice__(i, j, y) <==> x[i:j]=y
                   
                   Use  of negative indices is not supported.
        """
        pass
    ‘‘‘    
        
        
    def __sizeof__(self): # real signature unknown; restored from __doc__
        """ L.__sizeof__() -- size of L in memory, in bytes """
        pass

    __hash__ = None 列表占字节数

list

list(列表)功能详解

标签:

原文地址:http://www.cnblogs.com/dahuige/p/5129793.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!