zoukankan      html  css  js  c++  java
  • python初识第二篇

    python 编码:

    第一次编程有时候会遇到乱码的情况,就可以通过以下的情况来解决

    在Windows中默认的就是gbk编码,如果在代码头两部定义utf-8,系统还会按照系统的方式来定义。

    python2.7版过程:

    temp ="开心"   #utf-8
    temp_unicode = temp.decode("utf-8")
    temp_gbk = temp_unicode.encode("gbk")
    print(temp_gbk)
    
    
    解码,需要指定原来是什么编码
    decode 是解码
    编码,需要制定编成什么编码
    encode是编码

    python3 中 系统会自动定义 就不需要有上述操作了。

    运算符

    算数运算符:

    结果如下 :

    a = 10
    b = 20
    print a + b
    print a - b
    print a / b
    print a * b
    print a % b
    print a ** b
    print a // b
    
    
    D:Python27python.exe D:/untitled/day1.py
    30
    -10
    0
    200
    10
    100000000000000000000
    0
    
    Process finished with exit code 0

    比较运算符:

    结果如下   

    a = 10
    b = 20
    c = 0
    if a == b:
        print("")
    else:
         print("")
    
    
    if a != b:
        print("")
    else:
        print("")
    
    if a <> b:
        print("")
    else:
        print("")
    
    if a > b:
        print("")
    else:
        print("")
    
    if a < b:
        print("")
    else:
        print("")
    
    if a >= b:
        print("")
    else:
        print("")
    
    if a <= b:
        print("")
    else:
        print("")
    
    D:Python27python.exe D:/untitled/day1.py
    错
    对
    对
    错
    对
    错
    对
    
    Process finished with exit code 0


    赋值运算符:

    结果 :

    a = 10
    b = 20
    c = 0
    c = a + b
    print (c)
    c += a
    print (c)
    c -= a
    print (c)
    c *= a
    print (a)
    c /= a
    print (a)
    c %= a
    print (a)
    c **= a
    print (c)
    c //= a
    print (a)
    
    
    D:Python27python.exe D:/untitled/day1.py
    30
    40
    30
    10
    10
    10
    0
    10
    
    Process finished with exit code 0

    逻辑运算:

    代码如下:

    a = 10
    b = 20
    c = 0
    if a and b:
        print ('True')
    else:
        print ("False")
    if a or b:
        print ("True")
    else:
        print ("False")
    if not a and b:
        print ("Ture")
    else:
        print ("False")
    
    D:Python27python.exe D:/untitled/day1.py
    True
    True
    False
    
    Process finished with exit code 0

     成员 运算:

    代码如下

    # s = "kai xin"
    # q = "xin" in s #  
    # print(q)
    # 
    # s = ['xin',"kai","pi"]
    # q = "xin" not in s    
    # print(q)
    
    
    D:Python27python.exe D:/untitled/day1.py
    True
    False
    
    Process finished with exit code 0


    基本数据类型:

    数字 :int  整型

    • int(整型):整型或整数,是正或负整数,不带小数点。
    • long integers(长整型):无限大小的整数,整数最后是一个大写或小写的L。
    • floating point real values(长整型):浮点型由整数部分与小数部分组成,浮点型也可以使用科学计数法表示(2.5e2 = 2.5 x 102 = 250)
    • complex numbers(复数):复数由实数部分和虚数部分构成,可以用a + bj,或者complex(a,b)表示, 复数的实部a和虚部b都是浮点型
    #!/usr/bin/env python3
    
    class int(object):
        """
        int(x=0) -> integer
        int(x, base=10) -> integer
    
        Convert a number or string to an integer, or return 0 if no arguments
        are given.  If x is a number, return x.__int__().  For floating point
        numbers, this truncates towards zero.
    
        If x is not a number or if base is given, then x must be a string,
        bytes, or bytearray instance representing an integer literal in the
        given base.  The literal can be preceded by '+' or '-' and be surrounded
        by whitespace.  The base defaults to 10.  Valid bases are 0 and 2-36.
        Base 0 means to interpret the base from the string as an integer literal.
        >>> int('0b100', base=0)
        4
        """
        def bit_length(self): # real signature unknown; restored from __doc__
            """
            '''返回表示该数字的时占用的最少位数'''
            int.bit_length() -> int
    
            Number of bits necessary to represent self in binary.
            >>> bin(37)
            '0b100101'
            >>> (37).bit_length()
            6
            """
            return 0
    
        def conjugate(self, *args, **kwargs): # real signature unknown
            '''返回该复数的共轭复数'''
            """ Returns self, the complex conjugate of any int. """
            pass
    
        @classmethod # known case
        def from_bytes(cls, bytes, byteorder, *args, **kwargs): # real signature unknown; NOTE: unreliably restored from __doc__
            """
            int.from_bytes(bytes, byteorder, *, signed=False) -> int
    
            Return the integer represented by the given array of bytes.
    
            The bytes argument must be a bytes-like object (e.g. bytes or bytearray).
    
            The byteorder argument determines the byte order used to represent the
            integer.  If byteorder is 'big', the most significant byte is at the
            beginning of the byte array.  If byteorder is 'little', the most
            significant byte is at the end of the byte array.  To request the native
            byte order of the host system, use `sys.byteorder' as the byte order value.
    
            The signed keyword-only argument indicates whether two's complement is
            used to represent the integer.
            """
            pass
    
        def to_bytes(self, length, byteorder, *args, **kwargs): # real signature unknown; NOTE: unreliably restored from __doc__
            """
            int.to_bytes(length, byteorder, *, signed=False) -> bytes
    
            Return an array of bytes representing an integer.
    
            The integer is represented using length bytes.  An OverflowError is
            raised if the integer is not representable with the given number of
            bytes.
    
            The byteorder argument determines the byte order used to represent the
            integer.  If byteorder is 'big', the most significant byte is at the
            beginning of the byte array.  If byteorder is 'little', the most
            significant byte is at the end of the byte array.  To request the native
            byte order of the host system, use `sys.byteorder' as the byte order value.
    
            The signed keyword-only argument determines whether two's complement is
            used to represent the integer.  If signed is False and a negative integer
            is given, an OverflowError is raised.
            """
            pass
    
        def __abs__(self, *args, **kwargs): # real signature unknown
            '''返回绝对值'''
            """ abs(self) """
            pass
    
        def __add__(self, *args, **kwargs): # real signature unknown
            """ Return self+value. """
            pass
    
        def __and__(self, *args, **kwargs): # real signature unknown
            """ Return self&value. """
            pass
    
        def __bool__(self, *args, **kwargs): # real signature unknown
            """ self != 0 """
            pass
    
        def __ceil__(self, *args, **kwargs): # real signature unknown
            """ Ceiling of an Integral returns itself. """
            pass
    
        def __divmod__(self, *args, **kwargs): # real signature unknown
            '''相除,得到商和余数组成的元组'''
            """ Return divmod(self, value). """
            pass
    
        def __eq__(self, *args, **kwargs): # real signature unknown
            """ Return self==value. """
            pass
    
        def __float__(self, *args, **kwargs): # real signature unknown
            '''转换为浮点类型'''
            """ float(self) """
            pass
    
        def __floordiv__(self, *args, **kwargs): # real signature unknown
            """ Return self//value. """
            pass
    
        def __floor__(self, *args, **kwargs): # real signature unknown
            """ Flooring an Integral returns itself. """
            pass
    
        def __format__(self, *args, **kwargs): # real signature unknown
            pass
    
        def __getattribute__(self, *args, **kwargs): # real signature unknown
            '''内部调用 __new__方法或创建对象时传入参数使用'''
            """ Return getattr(self, name). """
            pass
    
        def __getnewargs__(self, *args, **kwargs): # real signature unknown
            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 __hash__(self, *args, **kwargs): # real signature unknown
            '''如果对象object为哈希表类型,返回对象object的哈希值。哈希值为整数。在字典查找中,哈希值用于快速比较字典的键。两个数值如果相等,则哈希值也相等。'''
            """ Return hash(self). """
            pass
    
        def __index__(self, *args, **kwargs): # real signature unknown
            '''用于切片,数字无意义'''
            """ Return self converted to an integer, if self is suitable for use as an index into a list. """
            pass
    
        def __init__(self, x, base=10): # known special case of int.__init__
            '''构造方法,执行 x = 123 或 x = int(10) 时,自动调用,暂时忽略'''
            """
            int(x=0) -> integer
            int(x, base=10) -> integer
    
            Convert a number or string to an integer, or return 0 if no arguments
            are given.  If x is a number, return x.__int__().  For floating point
            numbers, this truncates towards zero.
    
            If x is not a number or if base is given, then x must be a string,
            bytes, or bytearray instance representing an integer literal in the
            given base.  The literal can be preceded by '+' or '-' and be surrounded
            by whitespace.  The base defaults to 10.  Valid bases are 0 and 2-36.
            Base 0 means to interpret the base from the string as an integer literal.
            >>> int('0b100', base=0)
            4
            # (copied from class doc)
            """
            pass
    
        def __int__(self, *args, **kwargs): # real signature unknown
            '''转换为整数'''
            """ int(self) """
            pass
    
        def __invert__(self, *args, **kwargs): # real signature unknown
            """ ~self """
            pass
    
        def __le__(self, *args, **kwargs): # real signature unknown
            """ Return self<=value. """
            pass
    
        def __lshift__(self, *args, **kwargs): # real signature unknown
            """ Return self<<value. """
            pass
    
        def __lt__(self, *args, **kwargs): # real signature unknown
            """ Return self<value. """
            pass
    
        def __mod__(self, *args, **kwargs): # real signature unknown
            """ Return self%value. """
            pass
    
        def __mul__(self, *args, **kwargs): # real signature unknown
            """ Return self*value. """
            pass
    
        def __neg__(self, *args, **kwargs): # real signature unknown
            """ -self """
            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 __or__(self, *args, **kwargs): # real signature unknown
            """ Return self|value. """
            pass
    
        def __pos__(self, *args, **kwargs): # real signature unknown
            """ +self """
            pass
    
        def __pow__(self, *args, **kwargs): # real signature unknown
            """ Return pow(self, value, mod). """
            pass
    
        def __radd__(self, *args, **kwargs): # real signature unknown
            """ Return value+self. """
            pass
    
        def __rand__(self, *args, **kwargs): # real signature unknown
            """ Return value&self. """
            pass
    
        def __rdivmod__(self, *args, **kwargs): # real signature unknown
            """ Return divmod(value, self). """
            pass
    
        def __repr__(self, *args, **kwargs): # real signature unknown
            """ Return repr(self). """
            pass
    
        def __rfloordiv__(self, *args, **kwargs): # real signature unknown
            """ Return value//self. """
            pass
    
        def __rlshift__(self, *args, **kwargs): # real signature unknown
            """ Return value<<self. """
            pass
    
        def __rmod__(self, *args, **kwargs): # real signature unknown
            """ Return value%self. """
            pass
    
        def __rmul__(self, *args, **kwargs): # real signature unknown
            """ Return value*self. """
            pass
    
        def __ror__(self, *args, **kwargs): # real signature unknown
            """ Return value|self. """
            pass
    
        def __round__(self, *args, **kwargs): # real signature unknown
            """
            Rounding an Integral returns itself.
            Rounding with an ndigits argument also returns an integer.
            """
            pass
    
        def __rpow__(self, *args, **kwargs): # real signature unknown
            """ Return pow(value, self, mod). """
            pass
    
        def __rrshift__(self, *args, **kwargs): # real signature unknown
            """ Return value>>self. """
            pass
    
        def __rshift__(self, *args, **kwargs): # real signature unknown
            """ Return self>>value. """
            pass
    
        def __rsub__(self, *args, **kwargs): # real signature unknown
            """ Return value-self. """
            pass
    
        def __rtruediv__(self, *args, **kwargs): # real signature unknown
            """ Return value/self. """
            pass
    
        def __rxor__(self, *args, **kwargs): # real signature unknown
            """ Return value^self. """
            pass
    
        def __sizeof__(self, *args, **kwargs): # real signature unknown
            """ Returns size in memory, in bytes """
            pass
    
        def __str__(self, *args, **kwargs): # real signature unknown
            '''转换为人阅读的形式,如果没有适于人阅读的解释形式的话,则返回解释器课阅读的形式'''
            """ Return str(self). """
            pass
    
        def __sub__(self, *args, **kwargs): # real signature unknown
            """ Return self-value. """
            pass
    
        def __truediv__(self, *args, **kwargs): # real signature unknown
            """ Return self/value. """
            pass
    
        def __trunc__(self, *args, **kwargs): # real signature unknown
            """ Truncating an Integral returns itself. """
            pass
    
        def __xor__(self, *args, **kwargs): # real signature unknown
            """ Return self^value. """
            pass
    
        denominator = property(lambda self: object(), lambda self, v: None, lambda self: None)  # default
        """the denominator of a rational number in lowest terms"""
    
        imag = property(lambda self: object(), lambda self, v: None, lambda self: None)  # default
        """the imaginary part of a complex number"""
    
        numerator = property(lambda self: object(), lambda self, v: None, lambda self: None)  # default
        """the numerator of a rational number in lowest terms"""
    
        real = property(lambda self: object(), lambda self, v: None, lambda self: None)  # default
        """the real part of a complex number"""
    
    int(整型)
    int 类型

    以上函数常用的有:

    函数返回值 ( 描述 )
    abs(x) 返回数字的绝对值,如abs(-10) 返回 10
    ceil(x)  返回数字的上入整数,如math.ceil(4.1) 返回 5

    cmp(x, y)

    如果 x < y 返回 -1, 如果 x == y 返回 0, 如果 x > y 返回 1。 Python 3 已废弃 。使用 使用 (x>y)-(x<y) 替换。 
    exp(x)  返回e的x次幂(ex),如math.exp(1) 返回2.718281828459045
    fabs(x) 返回数字的绝对值,如math.fabs(-10) 返回10.0
    floor(x)  返回数字的下舍整数,如math.floor(4.9)返回 4
    log(x)  如math.log(math.e)返回1.0,math.log(100,10)返回2.0
    log10(x)  返回以10为基数的x的对数,如math.log10(100)返回 2.0
    max(x1, x2,...)  返回给定参数的最大值,参数可以为序列。
    min(x1, x2,...)  返回给定参数的最小值,参数可以为序列。
    modf(x)  返回x的整数部分与小数部分,两部分的数值符号与x相同,整数部分以浮点型表示。
    pow(x, y) x**y 运算后的值。
    round(x [,n]) 返回浮点数x的四舍五入值,如给出n值,则代表舍入到小数点后的位数。
    sqrt(x)  返回数字x的平方根,数字可以为负数,返回类型为实数,如math.sqrt(4)返回 2+0j

     布尔值 :

    真或假  1或0 (True or False) 在任何语言中都是至关重要的,它们可以使我们根据变量的真假值来做出判断,通过代码可以用来控制程序的路径。在 Python 中,布尔值的首字母是大写的True 和 False。

    q1 = 0
    print (bool(q1))
    
    q2 = 1
    print (bool(q2))

    通过调用bool方法,传入我们的变量给其做参数,返回True 或者 False。空值或者None(Python中类似其它语言Null 或者 Nil 的值)都会被认为是 False ,而其它情形则被认为是 True。

    字符串:
     str  Python的字符串是一个有序的字符集合,有序指的是可以通过偏移来访问每个字符,每个字符有严格的从左到右的位置顺序,类似于数组。Python中没有单个字符的类型(C语言中的char),取而代之的是使用一个字符的字符串。字符串是不可变序列,不可以在原处修改,也就是无法执行类似str[0] = 'x'的操作,而执行合并(str1 + str2)、修改字符串(str.replace(..))及分片(s[1:3])等字符串操作都是生成新的对象。

    代码如下

    #!/usr/bin/env python3
    
    str
    
    class str(object):
        """
        str(object='') -> str
        str(bytes_or_buffer[, encoding[, errors]]) -> str
    
        Create a new string object from the given object. If encoding or
        errors is specified, then the object must expose a data buffer
        that will be decoded using the given encoding and error handler.
        Otherwise, returns the result of object.__str__() (if defined)
        or repr(object).
        encoding defaults to sys.getdefaultencoding().
        errors defaults to 'strict'.
        """
        def capitalize(self): # real signature unknown; restored from __doc__
            '''将字符串的第一个字符转换为大写'''
            """
            S.capitalize() -> str
    
            Return a capitalized version of S, i.e. make the first character
            have upper case and the rest lower case.
            """
            return ""
    
        def casefold(self): # real signature unknown; restored from __doc__
            """
            S.casefold() -> str
    
            Return a version of S suitable for caseless comparisons.
            """
            return ""
    
        def center(self, width, fillchar=None): # real signature unknown; restored from __doc__
            '''返回一个指定的宽度 width 居中的字符串,fillchar 为填充的字符,默认为空格。'''
            """
            S.center(width[, fillchar]) -> str
    
            Return S centered in a string of length width. Padding is
            done using the specified fill character (default is a space)
            """
            return ""
    
        def count(self, sub, start=None, end=None): # real signature unknown; restored from __doc__
            '''返回 str 在 string 里面出现的次数,如果 beg 或者 end 指定则返回指定范围内 str 出现的次数
    '''
            """
            S.count(sub[, start[, end]]) -> int
    
            Return the number of non-overlapping occurrences of substring sub in
            string S[start:end].  Optional arguments start and end are
            interpreted as in slice notation.
            """
            return 0
    
        def encode(self, encoding='utf-8', errors='strict'): # real signature unknown; restored from __doc__
            '''以 encoding 指定的编码格式编码字符串,如果出错默认报一个ValueError 的异常,除非 errors 指定的是'ignore'或者'replace'''
            """
            S.encode(encoding='utf-8', errors='strict') -> bytes
    
            Encode S using the codec registered for encoding. Default encoding
            is 'utf-8'. errors may be given to set a different error
            handling scheme. Default is 'strict' meaning that encoding errors raise
            a UnicodeEncodeError. Other possible values are 'ignore', 'replace' and
            'xmlcharrefreplace' as well as any other name registered with
            codecs.register_error that can handle UnicodeEncodeErrors.
            """
            return b""
    
        def endswith(self, suffix, start=None, end=None): # real signature unknown; restored from __doc__
            '''检查字符串是否以 obj 结束,如果beg 或者 end 指定则检查指定的范围内是否以 obj 结束,如果是,返回 True,否则返回 False.'''
            """
            S.endswith(suffix[, start[, end]]) -> bool
    
            Return True if S ends with the specified suffix, False otherwise.
            With optional start, test S beginning at that position.
            With optional end, stop comparing S at that position.
            suffix can also be a tuple of strings to try.
            """
            return False
    
        def expandtabs(self, tabsize=8): # real signature unknown; restored from __doc__
            '''把字符串 string 中的 tab 符号转为空格,tab 符号默认的空格数是 8 。'''
            """
            S.expandtabs(tabsize=8) -> str
    
            Return a copy of S where all tab characters are expanded using spaces.
            If tabsize is not given, a tab size of 8 characters is assumed.
            """
            return ""
    
        def find(self, sub, start=None, end=None): # real signature unknown; restored from __doc__
            '''检测 str 是否包含在字符串中 中,如果 beg 和 end 指定范围,则检查是否包含在指定范围内,如果是返回开始的索引值,否则返回-1 '''
    
            """
            S.find(sub[, start[, end]]) -> int
    
            Return the lowest index in S where substring sub is found,
            such that sub is contained within S[start:end].  Optional
            arguments start and end are interpreted as in slice notation.
    
            Return -1 on failure.
            """
            return 0
    
        def format(*args, **kwargs): # known special case of str.format
            """
            S.format(*args, **kwargs) -> str
    
            Return a formatted version of S, using substitutions from args and kwargs.
            The substitutions are identified by braces ('{' and '}').
            """
            pass
    
        def format_map(self, mapping): # real signature unknown; restored from __doc__
            """
            S.format_map(mapping) -> str
    
            Return a formatted version of S, using substitutions from mapping.
            The substitutions are identified by braces ('{' and '}').
            """
            return ""
    
        def index(self, sub, start=None, end=None): # real signature unknown; restored from __doc__
            '''跟find()方法一样,只不过如果str不在字符串中会报一个异常.'''
            """
            S.index(sub[, start[, end]]) -> int
    
            Like S.find() but raise ValueError when the substring is not found.
            """
            return 0
    
        def isalnum(self): # real signature unknown; restored from __doc__
            '''如果字符串至少有一个字符并且所有字符都是字母或数字则返 回 True,否则返回 False'''
            """
            S.isalnum() -> bool
    
            Return True if all characters in S are alphanumeric
            and there is at least one character in S, False otherwise.
            """
            return False
    
        def isalpha(self): # real signature unknown; restored from __doc__
            '''如果字符串至少有一个字符并且所有字符都是字母则返回 True, 否则返回 False'''
            """
            S.isalpha() -> bool
    
            Return True if all characters in S are alphabetic
            and there is at least one character in S, False otherwise.
            """
            return False
    
        def isdecimal(self): # real signature unknown; restored from __doc__
            '''检查字符串是否只包含十进制字符,如果是返回 true,否则返回 false。'''
            """
            S.isdecimal() -> bool
    
            Return True if there are only decimal characters in S,
            False otherwise.
            """
            return False
    
        def isdigit(self): # real signature unknown; restored from __doc__
            '''如果字符串只包含数字则返回 True 否则返回 False..'''
            """
            S.isdigit() -> bool
    
            Return True if all characters in S are digits
            and there is at least one character in S, False otherwise.
            """
            return False
    
        def isidentifier(self): # real signature unknown; restored from __doc__
            """
            S.isidentifier() -> bool
    
            Return True if S is a valid identifier according
            to the language definition.
    
            Use keyword.iskeyword() to test for reserved identifiers
            such as "def" and "class".
            """
            return False
    
        def islower(self): # real signature unknown; restored from __doc__
            '''如果字符串中包含至少一个区分大小写的字符,并且所有这些(区分大小写的)字符都是小写,则返回 True,否则返回 False'''
            """
            S.islower() -> bool
    
            Return True if all cased characters in S are lowercase and there is
            at least one cased character in S, False otherwise.
            """
            return False
    
        def isnumeric(self): # real signature unknown; restored from __doc__
            '''如果字符串中只包含数字字符,则返回 True,否则返回 False'''
            """
            S.isnumeric() -> bool
    
            Return True if there are only numeric characters in S,
            False otherwise.
            """
            return False
    
        def isprintable(self): # real signature unknown; restored from __doc__
            """
            S.isprintable() -> bool
    
            Return True if all characters in S are considered
            printable in repr() or S is empty, False otherwise.
            """
            return False
    
        def isspace(self): # real signature unknown; restored from __doc__
            '''如果字符串中只包含空格,则返回 True,否则返回 False.'''
            """
            S.isspace() -> bool
    
            Return True if all characters in S are whitespace
            and there is at least one character in S, False otherwise.
            """
            return False
    
        def istitle(self): # real signature unknown; restored from __doc__
            '''如果字符串是标题化的(见 title())则返回 True,否则返回 False'''
            """
            S.istitle() -> bool
    
            Return True if S is a titlecased string and there is at least one
            character in S, i.e. upper- and titlecase characters may only
            follow uncased characters and lowercase characters only cased ones.
            Return False otherwise.
            """
            return False
    
        def isupper(self): # real signature unknown; restored from __doc__
            '''如果字符串中包含至少一个区分大小写的字符,并且所有这些(区分大小写的)字符都是大写,则返回 True,否则返回 False'''
            """
            S.isupper() -> bool
    
            Return True if all cased characters in S are uppercase and there is
            at least one cased character in S, False otherwise.
            """
            return False
    
        def join(self, iterable): # real signature unknown; restored from __doc__
            '''以指定字符串作为分隔符,将 seq 中所有的元素(的字符串表示)合并为一个新的字符串'''
            """
            S.join(iterable) -> str
    
            Return a string which is the concatenation of the strings in the
            iterable.  The separator between elements is S.
            """
            return ""
    
        def ljust(self, width, fillchar=None): # real signature unknown; restored from __doc__
            '''返回一个原字符串左对齐,并使用 fillchar 填充至长度 width 的新字符串,fillchar 默认为空格。'''
            """
            S.ljust(width[, fillchar]) -> str
    
            Return S left-justified in a Unicode string of length width. Padding is
            done using the specified fill character (default is a space).
            """
            return ""
    
        def lower(self): # real signature unknown; restored from __doc__
            '''转换字符串中所有大写字符为小写.'''
            """
            S.lower() -> str
    
            Return a copy of the string S converted to lowercase.
            """
            return ""
    
        def lstrip(self, chars=None): # real signature unknown; restored from __doc__
            '''截掉字符串左边的空格'''
            """
            S.lstrip([chars]) -> str
    
            Return a copy of the string S with leading whitespace removed.
            If chars is given and not None, remove characters in chars instead.
            """
            return ""
    
        def maketrans(self, *args, **kwargs): # real signature unknown
            '''创建字符映射的转换表,对于接受两个参数的最简单的调用方式,第一个参数是字符串,表示需要转换的字符,第二个参数也是字符串表示转换的目标。'''
            """
            Return a translation table usable for str.translate().
    
            If there is only one argument, it must be a dictionary mapping Unicode
            ordinals (integers) or characters to Unicode ordinals, strings or None.
            Character keys will be then converted to ordinals.
            If there are two arguments, they must be strings of equal length, and
            in the resulting dictionary, each character in x will be mapped to the
            character at the same position in y. If there is a third argument, it
            must be a string, whose characters will be mapped to None in the result.
            """
            pass
    
        def partition(self, sep): # real signature unknown; restored from __doc__
            """
            S.partition(sep) -> (head, sep, tail)
    
            Search for the separator sep in S, and return the part before it,
            the separator itself, and the part after it.  If the separator is not
            found, return S and two empty strings.
            """
            pass
    
        def replace(self, old, new, count=None): # real signature unknown; restored from __doc__
            '''把 将字符串中的 str1 替换成 str2,如果 max 指定,则替换不超过 max 次。'''
            """
            S.replace(old, new[, count]) -> str
    
            Return a copy of S with all occurrences of substring
            old replaced by new.  If the optional argument count is
            given, only the first count occurrences are replaced.
            """
            return ""
    
        def rfind(self, sub, start=None, end=None): # real signature unknown; restored from __doc__
            '''类似于 find()函数,不过是从右边开始查找.'''
            """
            S.rfind(sub[, start[, end]]) -> int
    
            Return the highest index in S where substring sub is found,
            such that sub is contained within S[start:end].  Optional
            arguments start and end are interpreted as in slice notation.
    
            Return -1 on failure.
            """
            return 0
    
        def rindex(self, sub, start=None, end=None): # real signature unknown; restored from __doc__
            '''类似于 index(),不过是从右边开始.'''
            """
            S.rindex(sub[, start[, end]]) -> int
    
            Like S.rfind() but raise ValueError when the substring is not found.
            """
            return 0
    
        def rjust(self, width, fillchar=None): # real signature unknown; restored from __doc__
            '''返回一个原字符串右对齐,并使用fillchar(默认空格)填充至长度 width 的新字符串'''
            """
            S.rjust(width[, fillchar]) -> str
    
            Return S right-justified in a string of length width. Padding is
            done using the specified fill character (default is a space).
            """
            return ""
    
        def rpartition(self, sep): # real signature unknown; restored from __doc__
            """
            S.rpartition(sep) -> (head, sep, tail)
    
            Search for the separator sep in S, starting at the end of S, and return
            the part before it, the separator itself, and the part after it.  If the
            separator is not found, return two empty strings and S.
            """
            pass
    
        def rsplit(self, sep=None, maxsplit=-1): # real signature unknown; restored from __doc__
    
            """
            S.rsplit(sep=None, maxsplit=-1) -> list of strings
    
            Return a list of the words in S, using sep as the
            delimiter string, starting at the end of the string and
            working to the front.  If maxsplit is given, at most maxsplit
            splits are done. If sep is not specified, any whitespace string
            is a separator.
            """
            return []
    
        def rstrip(self, chars=None): # real signature unknown; restored from __doc__
            '''删除字符串字符串末尾的空格.'''
            """
            S.rstrip([chars]) -> str
    
            Return a copy of the string S with trailing whitespace removed.
            If chars is given and not None, remove characters in chars instead.
            """
            return ""
    
        def split(self, sep=None, maxsplit=-1): # real signature unknown; restored from __doc__
    
            """
            S.split(sep=None, maxsplit=-1) -> list of strings
    
            Return a list of the words in S, using sep as the
            delimiter string.  If maxsplit is given, at most maxsplit
            splits are done. If sep is not specified or is None, any
            whitespace string is a separator and empty strings are
            removed from the result.
            """
            return []
    
        def splitlines(self, keepends=None): # real signature unknown; restored from __doc__
            """
            S.splitlines([keepends]) -> list of strings
    
            Return a list of the lines in S, breaking at line boundaries.
            Line breaks are not included in the resulting list unless keepends
            is given and true.
            """
            return []
    
        def startswith(self, prefix, start=None, end=None): # real signature unknown; restored from __doc__
            """
            S.startswith(prefix[, start[, end]]) -> bool
    
            Return True if S starts with the specified prefix, False otherwise.
            With optional start, test S beginning at that position.
            With optional end, stop comparing S at that position.
            prefix can also be a tuple of strings to try.
            """
            return False
    
        def strip(self, chars=None): # real signature unknown; restored from __doc__
            '''在字符串上执行 lstrip()和 rstrip()'''
            """
            S.strip([chars]) -> str
    
            Return a copy of the string S with leading and trailing
            whitespace removed.
            If chars is given and not None, remove characters in chars instead.
            """
            return ""
    
        def swapcase(self): # real signature unknown; restored from __doc__
            """
            S.swapcase() -> str
    
            Return a copy of S with uppercase characters converted to lowercase
            and vice versa.
            """
            return ""
    
        def title(self): # real signature unknown; restored from __doc__
            '''返回"标题化"的字符串,就是说所有单词都是以大写开始,其余字母均为小写(见 istitle())'''
            """
            S.title() -> str
    
            Return a titlecased version of S, i.e. words start with title case
            characters, all remaining cased characters have lower case.
            """
            return ""
    
        def translate(self, table): # real signature unknown; restored from __doc__
            """
            S.translate(table) -> str
    
            Return a copy of the string S in which each character has been mapped
            through the given translation table. The table must implement
            lookup/indexing via __getitem__, for instance a dictionary or list,
            mapping Unicode ordinals to Unicode ordinals, strings, or None. If
            this operation raises LookupError, the character is left untouched.
            Characters mapped to None are deleted.
            """
            return ""
    
        def upper(self): # real signature unknown; restored from __doc__
            '''转换字符串中的小写字母为大写'''
            """
            S.upper() -> str
    
            Return a copy of S converted to uppercase.
            """
            return ""
    
        def zfill(self, width): # real signature unknown; restored from __doc__
            '''返回长度为 width 的字符串,原字符串右对齐,前面填充0'''
            """
            S.zfill(width) -> str
    
            Pad a numeric string S with zeros on the left, to fill a field
            of the specified width. The string S is never truncated.
            """
            return ""
    
        def __add__(self, *args, **kwargs): # real signature unknown
            """ Return self+value. """
            pass
    
        def __contains__(self, *args, **kwargs): # real signature unknown
            """ Return key in self. """
            pass
    
        def __eq__(self, *args, **kwargs): # real signature unknown
            """ Return self==value. """
            pass
    
        def __format__(self, format_spec): # real signature unknown; restored from __doc__
            """
            S.__format__(format_spec) -> str
    
            Return a formatted version of S as described by format_spec.
            """
            return ""
    
        def __getattribute__(self, *args, **kwargs): # real signature unknown
            """ Return getattr(self, name). """
            pass
    
        def __getitem__(self, *args, **kwargs): # real signature unknown
            """ Return self[key]. """
            pass
    
        def __getnewargs__(self, *args, **kwargs): # real signature unknown
            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 __hash__(self, *args, **kwargs): # real signature unknown
            """ Return hash(self). """
            pass
    
        def __init__(self, value='', encoding=None, errors='strict'): # known special case of str.__init__
            """
            str(object='') -> str
            str(bytes_or_buffer[, encoding[, errors]]) -> str
    
            Create a new string object from the given object. If encoding or
            errors is specified, then the object must expose a data buffer
            that will be decoded using the given encoding and error handler.
            Otherwise, returns the result of object.__str__() (if defined)
            or repr(object).
            encoding defaults to sys.getdefaultencoding().
            errors defaults to 'strict'.
            # (copied from class doc)
            """
            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
    
        def __mod__(self, *args, **kwargs): # real signature unknown
            """ Return self%value. """
            pass
    
        def __mul__(self, *args, **kwargs): # real signature unknown
            """ Return self*value.n """
            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 __rmod__(self, *args, **kwargs): # real signature unknown
            """ Return value%self. """
            pass
    
        def __rmul__(self, *args, **kwargs): # real signature unknown
            """ Return self*value. """
            pass
    
        def __sizeof__(self): # real signature unknown; restored from __doc__
            """ S.__sizeof__() -> size of S in memory, in bytes """
            pass
    
        def __str__(self, *args, **kwargs): # real signature unknown
            """ Return str(self). """
            pass
    
    str(字符串)
    str
    # a = "kai xin hao       shuai kai"
    # print a.capitalize()  #将首字母大写
    # print len(a)  #输出字符串的总长度
    # print a.center(50,"*") # 将内容居中, 50为总长度,空白自定义
    # print a.count("xin",0,10)   #显示元素出现的次数 从0开始计算
    # print a.endswith("kai")  #判断是否已kai结束
    # print a.expandtabs(20)  # 	 表示tab键 将tab 转换为空格,一个tab默认8 个空格
    # print a.find("l")     #查找子序列位置,找不到返回-1
    # q = 'hello {0},age {1}'# 在字符串中当做占位符
    # print q.format('ha',20)   ##字符串 格式化
    # print a.isalnum()   #判断是不是字母和数字
    # print a.isalpha()   #判断是不是字母
    # print a.isdigit()   #判断是不是数字
    # print a.islower()   # 判断是不是小写
    # print a.isspace()   # 判断是不是空格
    # print a.istitle()   #判断是不是字符串中所有的单词拼写首字母是否为大写,且其他字母为小写则返回 True,否则返回 False
    # print a.isupper()   #判断是不是大写字母
    # print ''.join(a)    #以指定字符串作为分隔符,将 seq 中所有的元素(的字符串表示)合并为一个新的字符串  对应的值
    # print a.find('h')    # 找出'h'在字符串中的位置,
    # print a.find('h',10)  #从第十个位置开始搜索,返回h所在的位置
    # # print a.index('a')  #索引该元素在字符中的位置,如果没有就回报错
    # print a.ljust(50,'*')
    # #返回一个原字符串左对齐,并使用空格填充至指定长度的新字符串。如果指定的长度小于原字符串的长度则返回原字符串。
    # print a.lower()  #转换字串中所有的大写字符为小写
    # print a.lstrip('kai')  #用于截掉字符串左边的空格或指定字符
    # print a.partition('kai') #用来根据指定的分隔符将字符串进行分割,如果字符串包含指定的分隔符,则返回一个3元的tuple,第一个为分隔符左边的子串,第二个为分隔符本身,第三个为分隔符右边的子串
    # print a.rfind('k',0,10)  #反向查找 指定的范围
    # print a.rindex('k')  #反向查找索引
    # print a.rsplit('kai')  #从尾部开始删除
    # print a.swapcase()   #大小写进行转换,大写变小写小写变大写
    # print a.upper()     #将字符串的小写字母转为大写字母
    # print a.zfill(50)   #定字符串的长度。原字符串右对齐,前面填充0
    # #返回指定长度的字符串,原字符串右对齐,前面填充0
    #
    

    列表 :
    list []

    #!/usr/bin/env python3
    
    # list1 = ['alex','king','kangkang','abc',123]
    #
    # print(list1[0],list1[3])
    list
    
    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) -> None -- append object to end """
            pass
    
        def clear(self): # real signature unknown; restored from __doc__
            '''清除选中的列表'''
            """ L.clear() -> None -- remove all items from L """
            pass
    
        def copy(self): # real signature unknown; restored from __doc__
            '''复制列表'''
            """ L.copy() -> list -- a shallow copy of L """
            return []
    
        def count(self, value): # real signature unknown; restored from __doc__
            '''统计某个元素在列表中出现的次数'''
            """ L.count(value) -> integer -- return number of occurrences of value """
            return 0
    
        def extend(self, iterable): # real signature unknown; restored from __doc__
            '''在列表末尾一次性追加另一个序列中的多个值(用新列表扩展原来的列表)'''
            """ L.extend(iterable) -> None -- extend list by appending elements from the iterable """
            pass
    
        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) -> None -- 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, key=None, reverse=False): # real signature unknown; restored from __doc__
            '''对原列表进行排序'''
            """ L.sort(key=None, reverse=False) -> None -- stable sort *IN PLACE* """
            pass
    
        def __add__(self, *args, **kwargs): # real signature unknown
            """ Return self+value. """
            pass
    
        def __contains__(self, *args, **kwargs): # real signature unknown
            """ Return key in self. """
            pass
    
        def __delitem__(self, *args, **kwargs): # real signature unknown
            """ Delete self[key]. """
            pass
    
        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 __iadd__(self, *args, **kwargs): # real signature unknown
            """ Implement self+=value. """
            pass
    
        def __imul__(self, *args, **kwargs): # real signature unknown
            """ Implement self*=value. """
            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
    
        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
    
        def __mul__(self, *args, **kwargs): # real signature unknown
            """ Return self*value.n """
            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 __reversed__(self): # real signature unknown; restored from __doc__
            """ L.__reversed__() -- return a reverse iterator over the list """
            pass
    
        def __rmul__(self, *args, **kwargs): # real signature unknown
            """ Return self*value. """
            pass
    
        def __setitem__(self, *args, **kwargs): # real signature unknown
            """ Set self[key] to value. """
            pass
    
        def __sizeof__(self): # real signature unknown; restored from __doc__
            """ L.__sizeof__() -- size of L in memory, in bytes """
            pass
    
        __hash__ = None
    
    list(列表)
    list
    #namelist = ["wuyongcong", "wangzhikang", "sunqihu", "guokaixin", "sunlieqi",
    #            "qiqi", "didi", "wiwi", "eiei", "riri", "aiai",
    #            "sisi", "didi", "wiwi", "fifi", "riri", "gigi", "hihi"]
    # # # print(namelist)
    # print(namelist[3]) #获取列表指定位置的内容
    # print(namelist[2:5]) #取列表指定位置之间的内容但不包括该位置的内容
    # print namelist.index("eiei") #索引 获取某一个内容的位置 从0开始计算
    # print(namelist[7])#取指定的一个位置的内容
    # x = namelist.index("eiei") #索引将列表中一个值赋值给x
    # print namelist[x] # 获取该内容
    # print (namelist[-1])# 获取列表最后一个内容
    # print (namelist[-3:]) #取列表倒数三个值
    # print (namelist[:5]) #取列表前五个值
    # print (namelist[0:10:2]) #跳着按顺序查找
    # print (namelist.count("riri"))  # 统计列表里有几个同样的值
    # print (namelist.index("didi")) #索引 列表值里的位置
    # q = namelist.index("didi") #索引位置赋值
    # print(q)
    # namelist[q] = "new_didi" #修改内容
    # print(q)
    # print(namelist)#获取列表中的内容
    # print(q)
    #
    # w = namelist.count("riri")  # 统计次数
    # for q in range(w):  # 循环次数
    #     namelist.remove("riri")  # 删除指定内容
    # print(namelist)
    # q = (namelist.index("guokaixin"))# 索引指定内容赋值给q
    # namelist.insert(q+1,"laodi")#插入某一个元素
    # print(namelist)
    # namelist.sort()# 排序内容  默认从数字,空格,字母开始。
    # print(namelist)
    # namelist.append("dage") #追加一个内容
    # print(namelist)
    # namelist.reverse() #反转倒序
    # chongxin = ["zzz","xxx","ccc"]
    # namelist.extend(chongxin)   #扩展批量添加
    # print(namelist)
    # namelist.insert(3,"shabi") #向指定位置插入内容
    # print (namelist)
    # namelist.pop(-2) #将列表倒数第二个删除
    # print(namelist)
    # del namelist[2:5] #删除指定位置的内容
    # print(namelist)
    # chongxin2 = (namelist[-3:])  #将列表指定内容赋值给chongxin2获取该内容
    # print(chongxin2)

    元祖:tuple()与列表类似,但是列表可修改,元组不可修改, 不可增删改操作

    #!/usr/bin/env python3
    
    # tup1 = ('alex','king','kangkang','abc',123)
    tuple
    
    class tuple(object):
        """
        tuple() -> empty tuple
        tuple(iterable) -> tuple initialized from iterable's items
    
        If the argument is a tuple, the return value is the same object.
        """
        def count(self, value): # real signature unknown; restored from __doc__
            '''统计某个元素在元组中出现的次数'''
            """ T.count(value) -> integer -- return number of occurrences of value """
            return 0
    
        def index(self, value, start=None, stop=None): # real signature unknown; restored from __doc__
            '''从元组中找出某个值第一个匹配项的索引位置'''
            """
            T.index(value, [start, [stop]]) -> integer -- return first index of value.
            Raises ValueError if the value is not present.
            """
            return 0
    
        def __add__(self, *args, **kwargs): # real signature unknown
            """ Return self+value. """
            pass
    
        def __contains__(self, *args, **kwargs): # real signature unknown
            """ Return key in self. """
            pass
    
        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, *args, **kwargs): # real signature unknown
            """ Return self[key]. """
            pass
    
        def __getnewargs__(self, *args, **kwargs): # real signature unknown
            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 __hash__(self, *args, **kwargs): # real signature unknown
            """ Return hash(self). """
            pass
    
        def __init__(self, seq=()): # known special case of tuple.__init__
            """
            tuple() -> empty tuple
            tuple(iterable) -> tuple initialized from iterable's items
    
            If the argument is a tuple, the return value is the same object.
            # (copied from class doc)
            """
            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
    
        def __mul__(self, *args, **kwargs): # real signature unknown
            """ Return self*value.n """
            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 __rmul__(self, *args, **kwargs): # real signature unknown
            """ Return self*value. """
            pass
    
    tuple(元组)
    tuple

    namelist = tuple (("xin","pi","ai","si","ci")) # namelist[0] #索引获取列表中该位置的内容 # print(namelist) # namelist[len (namelist)-2] #拉长该位置的内容 # print(namelist) # namelist[0:3] #切片 # print(namelist) # i = namelist # for i in namelist: #将列表循环列出 # print (i) # #namelist.del [2] #元祖不支持删除 # q = namelist.count("pi") #获取次数 # print(q) # namelist.index("xin") #获取该内容的索引位置


    字典:dict

    字典(dictionary)是除列表意外python之中最灵活的内置数据结构类型。列表是有序的对象结合,字典是无序的对象集合。两者之间的区别在于:字典当中的元素是通过键来存取的,而不是通过偏移存取

    #!/usr/bin/env python3
    
    dic1 = {
        'alex':'good',
        'wuSIR':'good',
        'wb':'DSB'
    }
    
    print(dic1['wb'],dic1['wuSIR'])
    
    dict
    
    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)
        """
        def clear(self): # real signature unknown; restored from __doc__
            '''清除内容'''
            """ D.clear() -> None.  Remove all items from D. """
            pass
    
        def copy(self): # real signature unknown; restored from __doc__
            '''浅拷贝'''
            """ D.copy() -> a shallow copy of D """
            pass
    
        @staticmethod # known case
        def fromkeys(*args, **kwargs): # real signature unknown
            """ Returns a new dict with keys from iterable and values equal to value. """
            pass
    
        def get(self, k, d=None): # real signature unknown; restored from __doc__
            '''根据key获取值,d是默认值'''
            """ D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None. """
            pass
    
        def items(self): # real signature unknown; restored from __doc__
            '''所有项的列表形式'''
            """ D.items() -> a set-like object providing a view on D's items """
            pass
    
        def keys(self): # real signature unknown; restored from __doc__
            """ 所有的key列表 """
            """ D.keys() -> a set-like object providing a view on D's keys """
            pass
    
        def pop(self, k, d=None): # real signature unknown; restored from __doc__
            """ 获取并在字典中移除 """
            """
            D.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
            """
            pass
    
        def popitem(self): # real signature unknown; restored from __doc__
            '''获取并在字典中移除'''
            """
            D.popitem() -> (k, v), remove and return some (key, value) pair as a
            2-tuple; but raise KeyError if D is empty.
            """
            pass
    
        def setdefault(self, k, d=None): # real signature unknown; restored from __doc__
            '''如果key不存在,则创建,如果存在,则返回已存在的值且不修改'''
            """ D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D """
            pass
    
        def update(self, E=None, **F): # known special case of dict.update
            '''更新'''
            """
            D.update([E, ]**F) -> None.  Update D from dict/iterable E and F.
            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
    
        def values(self): # real signature unknown; restored from __doc__
            '''所有的值'''
            """ D.values() -> an object providing a view on D's values """
            pass
    
        def __contains__(self, *args, **kwargs): # real signature unknown
            """ True if D has a key k, else False. """
            pass
    
        def __delitem__(self, *args, **kwargs): # real signature unknown
            """ Delete self[key]. """
            pass
    
        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__
            """
            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)
            # (copied from class doc)
            """
            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
    dic
    # user_info = {0: "laoda","age":34,2:"k"}
    # print (user_info[0]) #索引获取内容
    # print (user_info["age"])
    # for i in user_info:
    #     print (i)
    # print(user_info.keys())  #获取所有的键
    # print(user_info.values()) #获取所有的值
    # print (user_info.items())  #获取所有键值对
    #
    # for i in user_info.keys():
    #     print(i)           #循环出所有的键
    # for i in user_info.values():
    #     print(i)           #循环出所有的值
    
    #user_info = {0:"alex","age":73,2:"m"}
    #for k,v in user_info.items():
    #     print (k)
    #     print (v)        # 循环出所有的键值对
    #
    # user_info.clear()
    # print (user_info)   #清除所有内容
    
    # val = user_info.get("age")
    # print (val)  #根据key获取值,如果key不存在,可以指定一个默认值
    # val = user_info.get("age","123")
    # print (val)    #如果键不存在输出一个123
    # print (user_info["age"])
    # # print (user_info["age1111"])  # 索引取值时。key不存在。报错
    # ret = "agfffe" in user_info.keys()
    # print (ret)     #判断为错
    
    # test = {"a1":123,'a2': 456}
    # del test["a1"]
    # print test   # 删除指定索引的键值对


       

  • 相关阅读:
    c++中ctype常用函数总结(isprint isblank..)
    c++的const总结(转)
    c++重载输入输出运算符
    c++中的友元重载
    c++函数模板二栈实现
    c++函数模板1
    c++中IO输入输出流总结<二>
    c++中IO输入输出流总结<一>
    四层与七层得区别(转)
    ORACLE操作
  • 原文地址:https://www.cnblogs.com/guokaixin/p/5450558.html
Copyright © 2011-2022 走看看