[转载] python学习笔记2--操作符,数据类型和内置功能

参考链接: Python中的Inplace运算符| 1(iadd(),isub(),iconcat()…)

什么是操作符? 

 简单的回答可以使用表达式4 + 5等于9,在这里4和5被称为操作数,+被称为操符。 Python语言支持操作者有以下几种类型。 

  算术运算符  比较(即关系)运算符  赋值运算符  逻辑运算符  位运算符  会员操作符  标识操作符 

 让我们逐一看看所有的运算符。 

 Python算术运算符: 

 操作符描述符例子+加法 - 对操作符的两侧增加值a + b = 30-减法 - 减去从左侧操作数右侧操作数a - b = -10*乘法 - 相乘的运算符两侧的值a * b = 200/除 - 由右侧操作数除以左侧操作数b / a = 2%模 - 由右侧操作数和余返回除以左侧操作数b % a = 0**指数- 执行对操作指数(幂)的计算a**b = 10 的幂 20//地板除 - 操作数的除法,其中结果是将小数点后的位数被除去的商。9//2 =  4 而 9.0//2.0 = 4.0

   

   

   

   

   

   

   

 

  

  

   

   #!/usr/bin/python

 

a = 21

b = 10

c = 0

 

c = a + b

print "Line 1 - Value of c is ", c

 

c = a - b

print "Line 2 - Value of c is ", c 

 

c = a * b

print "Line 3 - Value of c is ", c 

 

c = a / b

print "Line 4 - Value of c is ", c 

 

c = a % b

print "Line 5 - Value of c is ", c

 

a = 2

b = 3

c = a**b 

print "Line 6 - Value of c is ", c

 

a = 10

b = 5

c = a//b 

print "Line 7 - Value of c is ", c 

   

  算术运算符示例

  

 

  

  

   

   Line 1 - Value of c is 31

Line 2 - Value of c is 11

Line 3 - Value of c is 210

Line 4 - Value of c is 2

Line 5 - Value of c is 1

Line 6 - Value of c is 8

Line 7 - Value of c is 2 

   

  算术运算结果

  

   

  Python的比较操作符: 

 运算符描述示例==检查,两个操作数的值是否相等,如果是则条件变为真。(a == b) 不为 true.!=检查两个操作数的值是否相等,如果值不相等,则条件变为真。(a != b) 为 true.<>检查两个操作数的值是否相等,如果值不相等,则条件变为真。(a <> b) 为 true。这个类似于 != 运算符>检查左操作数的值是否大于右操作数的值,如果是,则条件成立。(a > b) 不为 true.<检查左操作数的值是否小于右操作数的值,如果是,则条件成立。(a < b) 为 true.>=检查左操作数的值是否大于或等于右操作数的值,如果是,则条件成立。(a >= b) 不为 true.<=检查左操作数的值是否小于或等于右操作数的值,如果是,则条件成立。(a <= b) 为 true.

   

   

   

   

   

   

 

  

  

   

   #!/usr/bin/python

 

a = 21

b = 10

c = 0

 

if ( a == b ):

   print "Line 1 - a is equal to b"

else:

   print "Line 1 - a is not equal to b"

 

if ( a != b ):

   print "Line 2 - a is not equal to b"

else:

   print "Line 2 - a is equal to b"

 

if ( a <> b ):

   print "Line 3 - a is not equal to b"

else:

   print "Line 3 - a is equal to b"

 

if ( a < b ):

   print "Line 4 - a is less than b" 

else:

   print "Line 4 - a is not less than b"

 

if ( a > b ):

   print "Line 5 - a is greater than b"

else:

   print "Line 5 - a is not greater than b"

 

a = 5;

b = 20;

if ( a <= b ):

   print "Line 6 - a is either less than or equal to  b"

else:

   print "Line 6 - a is neither less than nor equal to  b"

 

if ( b >= a ):

   print "Line 7 - b is either greater than  or equal to b"

else:

   print "Line 7 - b is neither greater than  nor equal to b" 

   

  比较操作符运算示例

  

 

  

  

   

   Line 1 - a is not equal to b

Line 2 - a is not equal to b

Line 3 - a is not equal to b

Line 4 - a is not less than b

Line 5 - a is greater than b

Line 6 - a is either less than or equal to b

Line 7 - b is either greater than or equal to b 

   

  比较操作符结果

  

   

   

 Python赋值运算符: 

 运算符描述示例=简单的赋值运算符,赋值从右侧操作数左侧操作数c = a + b将指定的值 a + b 到  c+=加法AND赋值操作符,它增加了右操作数左操作数和结果赋给左操作数c += a 相当于 c = c + a-=减AND赋值操作符,它减去右边的操作数从左边操作数,并将结果赋给左操作数c -= a 相当于 c = c - a*=乘法AND赋值操作符,它乘以右边的操作数与左操作数,并将结果赋给左操作数c *= a 相当于 c = c * a/=除法AND赋值操作符,它把左操作数与正确的操作数,并将结果赋给左操作数c /= a 相当于= c / a%=模量AND赋值操作符,它需要使用两个操作数的模量和分配结果左操作数c %= a is equivalent to c = c % a**=指数AND赋值运算符,执行指数(功率)计算操作符和赋值给左操作数c **= a 相当于 c = c ** a//=地板除,并分配一个值,执行地板除对操作和赋值给左操作数c //= a 相当于 c = c // a

   

   

   

   

   

   

 

  

  

   

   #!/usr/bin/python

 

a = 21

b = 10

c = 0

 

c = a + b

print "Line 1 - Value of c is ", c

 

c += a

print "Line 2 - Value of c is ", c 

 

c *= a

print "Line 3 - Value of c is ", c 

 

c /= a 

print "Line 4 - Value of c is ", c 

 

c  = 2

c %= a

print "Line 5 - Value of c is ", c

 

c **= a

print "Line 6 - Value of c is ", c

 

c //= a

print "Line 7 - Value of c is ", c

 

#----------------------结果-----------------------

Line 1 - Value of c is 31

Line 2 - Value of c is 52

Line 3 - Value of c is 1092

Line 4 - Value of c is 52

Line 5 - Value of c is 2

Line 6 - Value of c is 2097152

Line 7 - Value of c is 99864 

   

  赋值运算示例

  

   

 Python位运算符: 

  位运算符作用于位和位操作执行位。假设,如果a =60;且b =13;现在以二进制格式它们将如下: 

 a = 0011 1100 

 b = 0000 1101 

 ----------------- 

 a&b = 0000 1100 

 a|b = 0011 1101 

 a^b = 0011 0001 

 ~a  = 1100 0011 

 Python语言支持下位运算符 

   

 操作符描述示例&二进制和复制操作了一下,结果,如果它存在于两个操作数。(a & b) = 12 即 0000 1100|二进制或复制操作了一个比特,如果它存在一个操作数中。(a | b) = 61 即 0011 1101^二进制异或运算符的副本,如果它被设置在一个操作数而不是两个比特。(a ^ b) =  49 即  0011 0001~二进制的补运算符是一元的,并有“翻转”位的效果。(~a ) =  -61 即 1100 0011以2的补码形式由于带符号二进制数。<<二进位向左移位运算符。左操作数的值左移由右操作数指定的位数。a << 2 = 240 即 1111 0000>>二进位向右移位运算符。左操作数的值是由右操作数指定的位数向右移动。a >> 2 = 15 即 0000 1111

   

   

   

   

   

 

  

  

   

   #!/usr/bin/python

 

a = 60            # 60 = 0011 1100 

b = 13            # 13 = 0000 1101 

c = 0

 

c = a & b;        # 12 = 0000 1100

print "Line 1 - Value of c is ", c

 

c = a | b;        # 61 = 0011 1101 

print "Line 2 - Value of c is ", c

 

c = a ^ b;        # 49 = 0011 0001

print "Line 3 - Value of c is ", c

 

c = ~a;           # -61 = 1100 0011

print "Line 4 - Value of c is ", c

 

c = a << 2;       # 240 = 1111 0000

print "Line 5 - Value of c is ", c

 

c = a >> 2;       # 15 = 0000 1111

print "Line 6 - Value of c is ", c

 

#--------------------------------结果-------------------------

Line 1 - Value of c is 12

Line 2 - Value of c is 61

Line 3 - Value of c is 49

Line 4 - Value of c is -61

Line 5 - Value of c is 240

Line 6 - Value of c is 15 

   

  位运算符

  

   

 Python逻辑运算符: 

  Python语言支持以下逻辑运算符。 

   

 运算符描述示例and所谓逻辑与运算符。如果两个操作数都是真的,那么则条件成立。(a and b) 为 true.or所谓逻辑OR运算符。如果有两个操作数都是非零然后再条件变为真。(a or b) 为 true.not所谓逻辑非运算符。用于反转操作数的逻辑状态。如果一个条件为真,则逻辑非运算符将返回false。not(a and b) 为 false.

   

   

   

   

 

  

  

   

   #!/usr/bin/python

 

a = 10

b = 20

c = 0

 

if ( a and b ):

   print "Line 1 - a and b are true"

else:

   print "Line 1 - Either a is not true or b is not true"

 

if ( a or b ):

   print "Line 2 - Either a is true or b is true or both are true"

else:

   print "Line 2 - Neither a is true nor b is true"

 

 

a = 0

if ( a and b ):

   print "Line 3 - a and b are true"

else:

   print "Line 3 - Either a is not true or b is not true"

 

if ( a or b ):

   print "Line 4 - Either a is true or b is true or both are true"

else:

   print "Line 4 - Neither a is true nor b is true"

 

if not( a and b ):

   print "Line 5 - Either a is not true or b is not true"

else:

   print "Line 5 - a and b are true"

 

 

#---------------------------结果--------------------------------------

Line 1 - a and b are true

Line 2 - Either a is true or b is true or both are true

Line 3 - Either a is not true or b is not true

Line 4 - Either a is true or b is true or both are true

Line 5 - Either a is not true or b is not true 

   

  逻辑运算示例

  

   

 Python成员运算符: 

 Python成员运算符,在一个序列中成员资格的测试,如字符串,列表或元组。有两个成员运算符解释如下: 

   

 操作符描述示例in计算结果为true,如果它在指定找到变量的顺序,否则false。x在y中,在这里产生一个1,如果x是序列y的成员。not in计算结果为true,如果它不找到在指定的变量顺序,否则为false。x不在y中,这里产生结果不为1,如果x不是序列y的成员。

   

   

   

 

  

  

   

   #!/usr/bin/python

 

a = 10

b = 20

list = [1, 2, 3, 4, 5 ];

 

if ( a in list ):

   print "Line 1 - a is available in the given list"

else:

   print "Line 1 - a is not available in the given list"

 

if ( b not in list ):

   print "Line 2 - b is not available in the given list"

else:

   print "Line 2 - b is available in the given list"

 

a = 2

if ( a in list ):

   print "Line 3 - a is available in the given list"

else:

   print "Line 3 - a is not available in the given list"

 

#------------结果--------------------------------------

Line 1 - a is not available in the given list

Line 2 - b is not available in the given list

Line 3 - a is available in the given list 

   

  成员运算示例

  

   

 Python标识运算符: 

   

 运算符描述例子is计算结果为true,如果操作符两侧的变量指向相同的对象,否则为false。x是y,这里结果是1,如果id(x)的值为id(y)。is not计算结果为false,如果两侧的变量操作符指向相同的对象,否则为true。x不为y,这里结果不是1,当id(x)不等于id(y)。

   

   

   

 

  

  

   

   #!/usr/bin/python

 

a = 20

b = 20

 

if ( a is b ):

   print "Line 1 - a and b have same identity"

else:

   print "Line 1 - a and b do not have same identity"

 

if ( id(a) == id(b) ):

   print "Line 2 - a and b have same identity"

else:

   print "Line 2 - a and b do not have same identity"

 

b = 30

if ( a is b ):

   print "Line 3 - a and b have same identity"

else:

   print "Line 3 - a and b do not have same identity"

 

if ( a is not b ):

   print "Line 4 - a and b do not have same identity"

else:

   print "Line 4 - a and b have same identity"

 

#--------------------结果-------------------------------------------

Line 1 - a and b have same identity

Line 2 - a and b have same identity

Line 3 - a and b do not have same identity

Line 4 - a and b do not have same identity 

   

  标识运算符示例

  

   

 Python运算符优先级 

 下表列出了所有运算符从最高优先级到最低。 

   

 运算符描述**幂(提高到指数)~ + -补码,一元加号和减号(方法名的最后两个+@和 - @)* / % //乘,除,取模和地板除+ -加法和减法>> <<左,右按位转移&位'AND'^ |按位异'或`'和定期`或'<= < > >=比较运算符<> == !=等式运算符= %= /= //= -= += *= **=赋值运算符is is not标识运算符in not in成员运算符not or and逻辑运算符

  

   

   

   

   

   

   

 优先级 

   

 

  

  

   

   #!/usr/bin/python

 

a = 20

b = 10

c = 15

d = 5

e = 0

 

e = (a + b) * c / d       #( 30 * 15 ) / 5

print "Value of (a + b) * c / d is ",  e

 

e = ((a + b) * c) / d     # (30 * 15 ) / 5

print "Value of ((a + b) * c) / d is ",  e

 

e = (a + b) * (c / d);    # (30) * (15/5)

print "Value of (a + b) * (c / d) is ",  e

 

e = a + (b * c) / d;      #  20 + (150/5)

print "Value of a + (b * c) / d is ",  e

 

#-------------结果------------------------

Value of (a + b) * c / d is 90

Value of ((a + b) * c) / d is 90

Value of (a + b) * (c / d) is 90

Value of a + (b * c) / d is 50 

   

  运算符优先级示例

  

   

   

 数据类型和内置的功能 

 常用类功能查看方法 

 在pycharm里面 输入class的名称, 

 按住ctrl 单击会自己跳转到对应的class源码里面。 

  

  一、整数int的命令汇总 

  

   

   

    

    ''''''

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)

    """

 

    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()

        """

        return 0

 

    def conjugate(self, *args, **kwargs):  # real signature unknown

        """ Returns self, the complex conjugate of any int. 

        返回共轭复数

        >>> a=37

        >>> result=a.conjugate()

        >>> print (result)

        >>> a=-37

        >>> print(a.conjugate())

        -37        

        """

        pass

 

    @classmethod  # known case

    def from_bytes(cls, bytes, byteorder, *args,

                   **kwargs):  # real signature unknown; NOTE: unreliably restored from __doc__

        """

        不知道什么作用

        >>> a.from_bytes

        <built-in method from_bytes of type object at 0x000000001E283A30>

        >>> b=a.from_bytes

        >>> print(b)

        <built-in method from_bytes of type object at 0x000000001E283A30>

        >>> a=37

        >>> b=a.from_bytes()

        Traceback (most recent call last):

          File "<pyshell#18>", line 1, in <module>

            b=a.from_bytes()

        TypeError: Required argument 'bytes' (pos 1) not found

        加()后会报错。

        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) 

        取绝对值

        >>> a=-50

        >>> print(a.__abs__())

        

        """

        pass

 

    def __add__(self, *args, **kwargs):  # real signature unknown

        """ Return self+value. 

        相加

        >>> a=-50

        >>> print(a.__add__(100))

        >>> 

        """

        pass

 

    def __and__(self, *args, **kwargs):  # real signature unknown

        """ Return self&value.

         >>> a=255

        >>> print(bin(a))

        0b11111111

        >>> b=128

        >>> print(bin(b))

        0b10000000

        >>> print(a.__and__(b))

        进行二进制的与运算

        """

        pass

 

    def __bool__(self, *args, **kwargs):  # real signature unknown

        """ self != 0

        计算布尔值,只要不为0,结果就是True

        

        >>> a=35

        >>> print(a.__bool__())

        True

        >>> a=0

        >>> print(a.__bool__())

        False

        >>> a=-100

        >>> print(a.__bool__())

        True

         """

        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). 

        >>> a=91

        >>> print(a.__divmod__(9))

        (10, 1)

        

        """

        pass

 

    def __eq__(self, *args, **kwargs):  # real signature unknown

        """ Return self==value. 

        >>> a=91

        >>> print(a.__eq__(90))

        False

        判断是否相等,返回bool值

        """

        pass

 

    def __float__(self, *args, **kwargs):  # real signature unknown

        """ float(self) 

        转换为浮点数

        """

        pass

 

    def __floordiv__(self, *args, **kwargs):  # real signature unknown

        """ Return self//value.

        返回等于或小于代数商的最大整数值

        >>> a=91

        >>> print(a.__floordiv__(9))

        """

        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

        """ 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

        """ Return hash(self). 

        >>> a=91029393

        >>> print(a.__hash__())

        >>> 

        不知道什么原因输入的结果均为自己

        """

        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__

        """

        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)

        # (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

        >>> a=91

        >>> print(a.__invert__())

        -92

        >>> a=-90

        >>> print(a.__invert__())

        >>> a=90

        >>> print(a.__neg__())

        -90

        >>> a=-90

        >>> print(a.__neg__())

        """

        pass

 

    def __le__(self, *args, **kwargs):  # real signature unknown

        """ Return self<=value. """

        pass

 

    def __lshift__(self, *args, **kwargs):  # real signature unknown

        """ Return self<<value. 

        对二进制数值进行位移

        >>> a=2

        >>> print(bin(a))

        0b10

        >>> b=a.__lshift__(2)

        >>> print(b)

        >>> print(bin(b))

        0b1000

        >>> c=a.__rshift__(1)

        >>> print(bin(c))

        0b1

        >>> b

        >>> c

        """

        pass

 

    def __lt__(self, *args, **kwargs):  # real signature unknown

        """ Return self<value. """

        pass

 

    def __mod__(self, *args, **kwargs):  # real signature unknown

        """ Return self%value. 

        >>> a=91

        >>> print(a.__mod__(9))

       

        """

        pass

 

    def __mul__(self, *args, **kwargs):  # real signature unknown

        """ Return self*value. 

        乘法的意思

        >>> a=91

        >>> print(a.__mul__(9))

        >>> print(a.__mul__(2))

        """

        pass

 

    def __neg__(self, *args, **kwargs):  # real signature unknown

        """ -self 

        负数

        >>> a=91

        >>> print(a.__invert__())

        -92

        >>> a=-90

        >>> print(a.__invert__())

        >>> a=90

        >>> print(a.__neg__())

        -90

        >>> a=-90

        >>> print(a.__neg__())

        """

        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. 

        >>> a=255

        >>> bin(a)

        '0b11111111'

        >>> b=128

        >>> bin(b)

        '0b10000000'

        >>> c=a.__or__(b)

        >>> print(c)

        >>> bin(c)

        '0b11111111'

        >>> 

        """

        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. 

        >>> a=90

        >>> print(a.__truediv__(8))

        11.25

        >>> print(a.__div__(8))      

        """

        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"""

 

'''''' 

    

   class int

   

  二、浮点型float的命令汇总 

  

   

   

    

    class float(object):

    """

    float(x) -> floating point number

 

    Convert a string or number to a floating point number, if possible.

    """

 

    def as_integer_ratio(self):  # real signature unknown; restored from __doc__

        """

        float.as_integer_ratio() -> (int, int)

        输出一对,除于等于浮点数的整数

        Return a pair of integers, whose ratio is exactly equal to the original

        float and with a positive denominator.

        Raise OverflowError on infinities and a ValueError on NaNs.

 

        >>> (10.0).as_integer_ratio()

        (10, 1)

        >>> (0.0).as_integer_ratio()

        (0, 1)

        >>> (-.25).as_integer_ratio()

        (-1, 4)

        """

        pass

 

    def conjugate(self, *args, **kwargs):  # real signature unknown

        """ Return self, the complex conjugate of any float.

         >>> a=0.000000001

        >>> a.conjugate()

        1e-09

         """

        pass

 

    @staticmethod  # known case

    def fromhex(string):  # real signature unknown; restored from __doc__

        """

        float.fromhex(string) -> float

        十六进制文档转为10十进制浮点数

        Create a floating-point number from a hexadecimal string.

        >>> float.fromhex('0x1.ffffp10')

        2047.984375

        >>> float.fromhex('-0x1p-1074')

        -5e-324

        """

        return 0.0

 

    def hex(self):  # real signature unknown; restored from __doc__

        """

        float.hex() -> string

        转为十六进制

        Return a hexadecimal representation of a floating-point number.

        >>> (-0.1).hex()

        '-0x1.999999999999ap-4'

        >>> 3.14159.hex()

        '0x1.921f9f01b866ep+1'

        """

        return ""

 

    def is_integer(self, *args, **kwargs):  # real signature unknown

        """ Return True if the float is an integer. 

        判断是否整数

        >>> a=10.0000

        >>> a.is_integer()

        True

        >>> a=10.0001

        >>> a.is_integer()

        False

        """

        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 __bool__(self, *args, **kwargs):  # real signature unknown

        """ self != 0 

        布尔非0时候为真

        """

        pass

 

    def __divmod__(self, *args, **kwargs):  # real signature unknown

        """ Return divmod(self, value). 

        >>> a=91.0001

        >>> print(a.__divmod__(9))

        (10.0, 1.0001000000000033)

        >>> 

        """

        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 __format__(self, format_spec):  # real signature unknown; restored from __doc__

        """

        float.__format__(format_spec) -> string

 

        Formats the float according to format_spec.

        """

        return ""

 

    def __getattribute__(self, *args, **kwargs):  # real signature unknown

        """ Return getattr(self, name). """

        pass

 

    def __getformat__(self, typestr):  # real signature unknown; restored from __doc__

        """

        float.__getformat__(typestr) -> string

 

        You probably don't want to use this function.  It exists mainly to be

        used in Python's test suite.

 

        typestr must be 'double' or 'float'.  This function returns whichever of

        'unknown', 'IEEE, big-endian' or 'IEEE, little-endian' best describes the

        format of floating point numbers used by the C type named by typestr.

        """

        return ""

 

    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). 

        >>> print(a.__hash__())

        """

        pass

 

    def __init__(self, x):  # real signature unknown; restored from __doc__

        pass

 

    def __int__(self, *args, **kwargs):  # real signature unknown

        """ int(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. """

        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 __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 __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 __rmod__(self, *args, **kwargs):  # real signature unknown

        """ Return value%self. """

        pass

 

    def __rmul__(self, *args, **kwargs):  # real signature unknown

        """ Return value*self. """

        pass

 

    def __round__(self, *args, **kwargs):  # real signature unknown

        """

        Return the Integral closest to x, rounding half toward even.

        When an argument is passed, work like built-in round(x, ndigits).

        """

        pass

 

    def __rpow__(self, *args, **kwargs):  # real signature unknown

        """ Return pow(value, self, mod). """

        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 __setformat__(self, typestr, fmt):  # real signature unknown; restored from __doc__

        """

        float.__setformat__(typestr, fmt) -> None

 

        You probably don't want to use this function.  It exists mainly to be

        used in Python's test suite.

 

        typestr must be 'double' or 'float'.  fmt must be one of 'unknown',

        'IEEE, big-endian' or 'IEEE, little-endian', and in addition can only be

        one of the latter two if it appears to match the underlying C reality.

 

        Override the automatic determination of C-level floating point type.

        This affects how floats are converted to and from binary strings.

        """

        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

        """ Return the Integral closest to x between 0 and x.

        转为整数,不用四舍五入

        >>> a=91.49999999

        >>> print(a.__trunc__())

        >>> a=91.500000001

        >>> print(a.__trunc__())

        >>> a=91.999999999

        >>> print(a.__trunc__())

         """

        pass

 

    imag = property(lambda self: object(), lambda self, v: None, lambda self: None)  # default

    """the imaginary part of a complex number"""

 

    real = property(lambda self: object(), lambda self, v: None, lambda self: None)  # default

    """the real part of a complex number""" 

    

   class float

   

  三、字符串Str的命令汇总 

  

   

   

    

    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__

        """

        第一个字母转换为大写

        >>> a='winter'

        >>> print(a.capitalize())

        Winter

        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__

        """

        把所有的大小字面转换为小写字母

        >>> a='Winter'

        >>> print(a.casefold())

        winter

        >>> a='WinterSam'

        >>> print(a.casefold())

        wintersam

        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__

        """

        >>> a.center(40,"*")

        '*****************Winter*****************'

        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__

        """

        >>> a='Return S centered in a string of length width. Padding is done using the specified fill character (default is a space)'

        >>> a.count('a')

        >>> a.count('s')

        >>> a.count('a',0,40)

        >>> a.count('a',0,140)

        >>> a.count('a',0,80)

        >>> a.count('a',0,120)

        >>> a.count('a',80,120)

        >>> a.count("Return")

        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__

        """

        S.encode(encoding='utf-8', errors='strict') -> bytes

        查看http://www.cnblogs.com/wintershen/p/6673828.html

        

        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__

        """

        S.endswith(suffix[, start[, end]]) -> bool

        判断 最后一个是否为输入的

        >>> a='Return S centered in a string of length width. Padding is done using the specified fill character (default is a space)'

        >>> a.endswith("n")

        False

        >>> a.endswith(')')

        True

        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__

        """

        S.expandtabs(tabsize=8) -> str

        把tab 转为为8个空格

 

        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__

        """

        S.find(sub[, start[, end]]) -> int

        >>> a='Return S centered in a string of length width. Padding is done using the specified fill character (default is a space)'

        >>> a.find('Return')

        >>> a.find('space')

        >>> a.find('winter')

        -1

        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(self, *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__

        """

        S.index(sub[, start[, end]]) -> int

        >>> a.index('Return')

        >>> a.index('space')

        >>> a.index('winter')

        Traceback (most recent call last):

          File "<pyshell#46>", line 1, in <module>

            a.index('winter')

        ValueError: substring not found

        

        Like S.find() but raise ValueError when the substring is not found.

        """

        return 0

 

    def isalnum(self):  # real signature unknown; restored from __doc__

        """

        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__

        """

        S.isalpha() -> bool

        判断是否字母,只能全部均为字母

        >>> a='a'

        >>> a.isalpha()

        True

        >>> a='abc'

        >>> a.isalpha()

        True

        >>> a='abc abc'

        >>> a.isalpha()

        False

        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__

        """

        S.isdecimal() -> bool

        >>> a='1000'

        >>> a.isdecimal()

        True

        >>> a='0xff'

        >>> a.isdecimal()

        False

        >>> a.isalnum()

        True

        Return True if there are only decimal characters in S,

        False otherwise.

        """

        return False

 

    def isdigit(self):  # real signature unknown; restored from __doc__

        """

        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

        判断是否是一个单独的英文单词?

        >>> a='winter'

        >>> b='Winter is a man'

        >>> c='Winter Come'

        >>> a.isidentifier()

        True

        >>> b.isidentifier()

        False

        >>> c.isidentifier()

        False

        >>> d='100winter'

        >>> d.isidentifier()

        False

        >>> e='winter winter'

        False

        >>> e.isidentifier()

        >>> f='def'

        >>> f.isidentifier()

        True

        >>> g='abc'

        >>> g.isidentifier()

        True

        

        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__

        """

        S.islower() -> bool

        判断是否全部都是小写字母,包括特殊字符空格等等

        >>> a='winterS'

        >>> b='winter winter'

        >>> c='winterisamanandtherearemuchmore'

        >>> a.islower()

        False

        >>> b.islower()

        True

        >>> c.islower()

        True

        >>> d='winter is a *******'

        >>> d.islower()

        True

        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__

        """

        S.isnumeric() -> bool

        判断是否只是数字

        >>> a='winter100'

        >>> b='winter is 100'

        >>> a.isnumeric()

        False

        >>> b.isnumeric()

        False

        >>> c='123459384949'

        >>> c.isnumeric()

        True

        >>> d='0xff'

        >>> d.isnumeric()

        False

        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

        判断是否全部都可以打印

        >>> a='winter\nwinter'

        >>> print(a)

        winter

        winter

        >>> a.isprintable()

        False

        

        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__

        """

        S.isspace() -> bool

        判断是否为空

        >>> a='winter winter'

        >>> b='               '

        >>> c='     ' #tab

        >>> a.isspace()

        False

        >>> b.isspace()

        True

        >>> c.isspace()

        True

        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__

        """

        S.istitle() -> bool

        判断是否里面每一个单词对应的首字母均为大写

        >>> a="Winter is coming"

        >>> b='Winter Is Coming'

        >>> c='winteriscomIng'

        >>> a.istitle()

        False

        >>> b.istitle()

        True

        >>> c.istitle()

        False

        >>> d='Winteriscoming'

        >>> d.istitle()

        True

        

        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__

        """

        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__

        """

        S.join(iterable) -> str

        把输入拆开每一个字面,把S复制加入到每一个拆开的字符中间

        >>> a='winter'

        >>> b='11111'

        >>> c=a.join(b)

        >>> print(c)

        1winter1winter1winter1winter1

        

        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__

        """

        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__

        """

        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__

        """

        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__

        """

        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__

        """

        S.rjust(width[, fillchar]) -> str

        插入,与center功能类似

        >>> a='winter'

        >>> a.rjust(40,"*")

        '**********************************winter'

        

        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)

        从右向左寻找特定的词语,把找的词语有''表示出来

        >>> a.rpartition('part')

        ('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.')

        >>> print(a)

        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.

        >>> 

        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

        分割,按关键词把对应,关键字前后的内容分割为列表。可以设置分割多少个。

        >>> a.split('part')

        ['Search for the separator sep in S, starting at the end of S, and return the ', ' before it, the separator itself, and the ', ' after it.  If the separator is not found, return two empty strings and S.']

        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

        与endswitch类似,查看开头的内容是输入内容。

        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__

        """

        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

        大小字母互换。

        >>> a='winTER'

        >>> a.swapcase()

        'WINter'

        

        Return a copy of S with uppercase characters converted to lowercase

        and vice versa.

        """

        return ""

 

    def title(self):  # real signature unknown; restored from __doc__

        """

        S.title() -> str

        把字体转换为标题的格式

        >>> a='winTER'

        >>> a.title()

        'Winter'

        >>> a='winter is coming'

        >>> a.title()

        'Winter Is Coming'

        

        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

 

        转换,需要先做一个对应表,最后一个表示删除字符集合

        intab = "aeiou"

        outtab = "12345"

        trantab = maketrans(intab, outtab)  <<<<<maketrans is not defined in 3.5

        str = "this is string example....wow!!!"

        print str.translate(trantab, 'xm')

 

        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__

        """

        S.zfill(width) -> str

        输入长度,用0补充到对应长度

        >>> a.zfill(40)

        '000000000000000000000             winter'

        >>> a.zfill(8)

        '             winter'

        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 

    

   class str

   

  四、列表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 

        添加最后。

        >>> a=[1,2,]

        >>> print(a)

        [1, 2]

        >>> a.append('winter')

        >>> print(a)

        [1, 2, 'winter']

        >>> a.append('winter2',)

        >>> print(a)

        [1, 2, 'winter', 'winter2']

        

        """

        pass

 

    def clear(self): # real signature unknown; restored from __doc__

        """ L.clear() -> None -- remove all items from L 

        >>> print(a)

        [1, 2, 'winter', 'winter2']

        >>> a.clear()

        >>> print(a)

        []

        

        """

        pass

 

    def copy(self): # real signature unknown; restored from __doc__

        """ L.copy() -> list -- a shallow copy of L

        >>> a=['winter',1,2,0,]

        >>> a.copy()

        ['winter', 1, 2, 0]

        >>> print()

        

        >>> print(a)

        ['winter', 1, 2, 0]

        >>> b=['winter',]

        >>> a.copy(b)

        >>> b=a.copy()

        >>> print(b)

        ['winter', 1, 2, 0]

         

         """

        return []

 

    def count(self, value): # real signature unknown; restored from __doc__

        """ L.count(value) -> integer -- return number of occurrences of value

        >>> print(b)

        ['winter', 1, 2, 0]

        >>> b.count(1)

        >>> b.count(3)

        >>> b.count('winter')

         

         """

        return 0

 

    def extend(self, iterable): # real signature unknown; restored from __doc__

        """ L.extend(iterable) -> None -- extend list by appending elements from the iterable 

        >>> a=[1,2,3]

        >>> a.extend('1111')

        >>> print(a)

        [1, 2, 3, '1', '1', '1', '1']

        >>> a.extend([2,2])

        >>> print(a)

        [1, 2, 3, '1', '1', '1', '1', 2, 2]

        

        """

        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.

        >>> print(a)

        [1, 2, 3, '1', '1', '1', '1']

        >>> a.extend([2,2])

        >>> print(a)

        [1, 2, 3, '1', '1', '1', '1', 2, 2]

        >>> b=a.pop()

        >>> print(a)

        [1, 2, 3, '1', '1', '1', '1', 2]

        >>> print(b)

        >>> c=a.pop(1)

        >>> print(a)

        [1, 3, '1', '1', '1', '1', 2]

        >>> print(c)

        

        

        """

        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.

        

        >>> print(a)

        [1, 3, '1', '1', '1', '1', 2]

        >>> b=a.remove('1')

        >>> print(b)

        None

        >>> print(a)

        [1, 3, '1', '1', '1', 2]

        >>> a.insert('1',1)

        Traceback (most recent call last):

          File "<pyshell#70>", line 1, in <module>

            a.insert('1',1)

        TypeError: 'str' object cannot be interpreted as an integer

        >>>  a.insert(1,'1')

         

        SyntaxError: unexpected indent

        >>> a.insert(1,'1')

        >>> print(a)

        [1, '1', 3, '1', '1', '1', 2]

        >>> a.remove('1')

        >>> print(a)

        [1, 3, '1', '1', '1', 2]

        >>> a.remove(99)

        Traceback (most recent call last):

          File "<pyshell#76>", line 1, in <module>

            a.remove(99)

        ValueError: list.remove(x): x not in list

        """

        pass

 

    def reverse(self): # real signature unknown; restored from __doc__

        """ L.reverse() -- reverse *IN PLACE* 

        >>> print(a)

        [2, '1', '1', '1', 3, 1]

        >>> a.reverse()

        >>> print(a)

        [1, 3, '1', '1', '1', 2]

        """

        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* 

        排序,不能同时对字符串和数值排序

        >>> print(a)

        [1, 3, '1', '1', '1', 2]

        >>> a.sort()

        Traceback (most recent call last):

          File "<pyshell#83>", line 1, in <module>

            a.sort()

        TypeError: unorderable types: str() < int()

        >>> a.sort()

        Traceback (most recent call last):

          File "<pyshell#84>", line 1, in <module>

            a.sort()

        TypeError: unorderable types: str() < int()

        >>> b=[1,2,3,4,5,6,99,10,89]

        >>> b.sort()

        >>> print(b)

        [1, 2, 3, 4, 5, 6, 10, 89, 99]

        >>> c=['winter','winter2','eirc']

        >>> c.sort()

        >>> print(c)

        ['eirc', 'winter', 'winter2']

        >>> d=c.extend([14,3,5,1])

        >>> print(d)

        None

        >>> print(c)

        ['eirc', 'winter', 'winter2', 14, 3, 5, 1]

        >>> c.sort()

        Traceback (most recent call last):

          File "<pyshell#94>", line 1, in <module>

            c.sort()

        TypeError: unorderable types: int() < str()

        >>> 

        

        """

        pass

 

    def __add__(self, *args, **kwargs): # real signature unknown

        """ Return self+value.

        >>> a=[1,2,3]

        >>> a.__add__([1,2])

        [1, 2, 3, 1, 2]

         

         """

        pass

 

    def __contains__(self, *args, **kwargs): # real signature unknown

        """ Return key in self. 

        >>> a.__contains__(5)

        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 __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 

    

   class list

   

  五、元组tuple的命令汇总 

  

   

   

    

    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 

        添加最后。

        >>> a=[1,2,]

        >>> print(a)

        [1, 2]

        >>> a.append('winter')

        >>> print(a)

        [1, 2, 'winter']

        >>> a.append('winter2',)

        >>> print(a)

        [1, 2, 'winter', 'winter2']

        

        """

        pass

 

    def clear(self): # real signature unknown; restored from __doc__

        """ L.clear() -> None -- remove all items from L 

        >>> print(a)

        [1, 2, 'winter', 'winter2']

        >>> a.clear()

        >>> print(a)

        []

        

        """

        pass

 

    def copy(self): # real signature unknown; restored from __doc__

        """ L.copy() -> list -- a shallow copy of L

        >>> a=['winter',1,2,0,]

        >>> a.copy()

        ['winter', 1, 2, 0]

        >>> print()

        

        >>> print(a)

        ['winter', 1, 2, 0]

        >>> b=['winter',]

        >>> a.copy(b)

        >>> b=a.copy()

        >>> print(b)

        ['winter', 1, 2, 0]

         

         """

        return []

 

    def count(self, value): # real signature unknown; restored from __doc__

        """ L.count(value) -> integer -- return number of occurrences of value

        >>> print(b)

        ['winter', 1, 2, 0]

        >>> b.count(1)

        >>> b.count(3)

        >>> b.count('winter')

         

         """

        return 0

 

    def extend(self, iterable): # real signature unknown; restored from __doc__

        """ L.extend(iterable) -> None -- extend list by appending elements from the iterable 

        >>> a=[1,2,3]

        >>> a.extend('1111')

        >>> print(a)

        [1, 2, 3, '1', '1', '1', '1']

        >>> a.extend([2,2])

        >>> print(a)

        [1, 2, 3, '1', '1', '1', '1', 2, 2]

        

        """

        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.

        >>> print(a)

        [1, 2, 3, '1', '1', '1', '1']

        >>> a.extend([2,2])

        >>> print(a)

        [1, 2, 3, '1', '1', '1', '1', 2, 2]

        >>> b=a.pop()

        >>> print(a)

        [1, 2, 3, '1', '1', '1', '1', 2]

        >>> print(b)

        >>> c=a.pop(1)

        >>> print(a)

        [1, 3, '1', '1', '1', '1', 2]

        >>> print(c)

        

        

        """

        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.

        

        >>> print(a)

        [1, 3, '1', '1', '1', '1', 2]

        >>> b=a.remove('1')

        >>> print(b)

        None

        >>> print(a)

        [1, 3, '1', '1', '1', 2]

        >>> a.insert('1',1)

        Traceback (most recent call last):

          File "<pyshell#70>", line 1, in <module>

            a.insert('1',1)

        TypeError: 'str' object cannot be interpreted as an integer

        >>>  a.insert(1,'1')

         

        SyntaxError: unexpected indent

        >>> a.insert(1,'1')

        >>> print(a)

        [1, '1', 3, '1', '1', '1', 2]

        >>> a.remove('1')

        >>> print(a)

        [1, 3, '1', '1', '1', 2]

        >>> a.remove(99)

        Traceback (most recent call last):

          File "<pyshell#76>", line 1, in <module>

            a.remove(99)

        ValueError: list.remove(x): x not in list

        """

        pass

 

    def reverse(self): # real signature unknown; restored from __doc__

        """ L.reverse() -- reverse *IN PLACE* 

        >>> print(a)

        [2, '1', '1', '1', 3, 1]

        >>> a.reverse()

        >>> print(a)

        [1, 3, '1', '1', '1', 2]

        """

        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* 

        排序,不能同时对字符串和数值排序

        >>> print(a)

        [1, 3, '1', '1', '1', 2]

        >>> a.sort()

        Traceback (most recent call last):

          File "<pyshell#83>", line 1, in <module>

            a.sort()

        TypeError: unorderable types: str() < int()

        >>> a.sort()

        Traceback (most recent call last):

          File "<pyshell#84>", line 1, in <module>

            a.sort()

        TypeError: unorderable types: str() < int()

        >>> b=[1,2,3,4,5,6,99,10,89]

        >>> b.sort()

        >>> print(b)

        [1, 2, 3, 4, 5, 6, 10, 89, 99]

        >>> c=['winter','winter2','eirc']

        >>> c.sort()

        >>> print(c)

        ['eirc', 'winter', 'winter2']

        >>> d=c.extend([14,3,5,1])

        >>> print(d)

        None

        >>> print(c)

        ['eirc', 'winter', 'winter2', 14, 3, 5, 1]

        >>> c.sort()

        Traceback (most recent call last):

          File "<pyshell#94>", line 1, in <module>

            c.sort()

        TypeError: unorderable types: int() < str()

        >>> 

        

        """

        pass

 

    def __add__(self, *args, **kwargs): # real signature unknown

        """ Return self+value.

        >>> a=[1,2,3]

        >>> a.__add__([1,2])

        [1, 2, 3, 1, 2]

         

         """

        pass

 

    def __contains__(self, *args, **kwargs): # real signature unknown

        """ Return key in self. 

        >>> a.__contains__(5)

        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 __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 

    

   class tuple

   

  六、字典dict的命令汇总 字典为无序的。 

  创建字典: 

  dic1={‘winter':1,'winter2':2}  

  

   

   

    

    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 

        无法理解有什么作用

        >>> a={'winter':1,'winter2':2}

        >>> b=a

        >>> print(b)

        {'winter': 1, 'winter2': 2}

        >>> b=a.copy()

        >>> print(b)

        {'winter': 1, 'winter2': 2}

        """

        pass

 

    @staticmethod # known case

    def fromkeys(*args, **kwargs): # real signature unknown

        """ Returns a new dict with keys from iterable and values equal to value. 

        获取对应的字典里面的keys。

        >>> c={'111': 1, '222': 2}

        >>> c.fromkeys(a)

        {'winter': None, 'winter2': None}

        >>> print(c)

        {'111': 1, '222': 2}

        >>> print(a)

        {'winter': 1, 'winter2': 2}

        >>> 

        >>> d={'www':1}

        >>> d.fromkeys(c)

        {'111': None, '222': None}

        """

        pass

 

    def get(self, k, d=None): # real signature unknown; restored from __doc__

        """ D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None. 

        >>> print(c)

        {'111': 1, '222': 2}

        >>> c.get('111')

        >>> c.get('222')

        >>> c.get('winter')

        >>> c.get('winter','nothing')

        'nothing'

        """

        pass

 

    def items(self): # real signature unknown; restored from __doc__

        """ D.items() -> a set-like object providing a view on D's items 

        >>> c.items()

        dict_items([('111', 1), ('222', 2)])

        >>> e=c.items()

        >>> print(e)

        dict_items([('111', 1), ('222', 2)])

        >>> e[0]

        Traceback (most recent call last):

          File "<pyshell#141>", line 1, in <module>

            e[0]

        TypeError: 'dict_items' object does not support indexing

        >>> type(e)

        <class 'dict_items'>

        """

        pass

 

    def keys(self): # real signature unknown; restored from __doc__

        """ D.keys() -> a set-like object providing a view on D's keys

        获取所有的keys的值

         >>> c=a.keys()

        >>> print(c)

        dict_keys(['winter', 'winter2'])

        >>> type(c)

        <class 'dict_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

        >>> a

        {'winter': 1, 'winter2': 2}

        >>> c=a.pop('winter')

        >>> print(c)

        >>> print(a)

        {'winter2': 2}

        """

        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.

        弹出,注意popitem是从前向后弹出,而其他的pop是从后向前弹。

        >>> a={'winter': 1, 'winter2': 2}

        >>> c=a.popitem()

        >>> print(c)

        ('winter', 1)

        >>> print(a)

        {'winter2': 2}

        >>> a=[1,2,3,4]

        >>> c=a.pop()

        >>> print(a)

        [1, 2, 3]

        >>> print(c)

        """

        pass

 

    def setdefault(self, k, d=None): # real signature unknown; restored from __doc__

        """ D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D 

        设置key的值,如果没有这个key就直接添加

        >>> a={'winter':1,'winter2':2}

        >>> a.setdefault()

        Traceback (most recent call last):

          File "<pyshell#1>", line 1, in <module>

            a.setdefault()

        TypeError: setdefault expected at least 1 arguments, got 0

        >>> a.setdefault('winter')

        >>> print(a)

        {'winter': 1, 'winter2': 2}

        >>> a.setdault('winter3')

        Traceback (most recent call last):

          File "<pyshell#4>", line 1, in <module>

            a.setdault('winter3')

        AttributeError: 'dict' object has no attribute 'setdault'

        >>> a.setdefault('winter')

        >>> print(a)

        {'winter': 1, 'winter2': 2}

        >>> a.setdefault('winter3')

        >>> print(a)

        {'winter': 1, 'winter2': 2, 'winter3': None}

        >>> 

        >>> 

        >>> 

        >>> a.setdefault('winter4',4)

        >>> print(a)

        {'winter': 1, 'winter2': 2, 'winter3': None, 'winter4': 4}

        """

        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]

        >>> print(a)

        {'winter': 1, 'winter2': 2, 'winter3': None, 'winter4': 4}

        >>> a

        {'winter': 1, 'winter2': 2, 'winter3': None, 'winter4': 4}

        >>> b={'winter':111}

        >>> b.update(a)

        >>> b

        {'winter': 1, 'winter2': 2, 'winter3': None, 'winter4': 4}

        >>> c={'winter10':10}

        >>> c.update(b)

        >>> print(c)

        {'winter': 1, 'winter2': 2, 'winter3': None, 'winter4': 4, 'winter10': 10}

        >>> c.update(a,b)

        Traceback (most recent call last):

          File "<pyshell#21>", line 1, in <module>

            c.update(a,b)

        TypeError: update expected at most 1 arguments, got 2

        >>> c.update(a,**b)

        >>> print(c)

        {'winter2': 2, 'winter3': None, 'winter4': 4, 'winter10': 10, 'winter': 1}

        >>> print(b)

        {'winter': 1, 'winter2': 2, 'winter3': None, 'winter4': 4}

        

        """

        pass

 

    def values(self): # real signature unknown; restored from __doc__

        """ D.values() -> an object providing a view on D's values

         >>> print(b)

        {'winter': 1, 'winter2': 2, 'winter3': None, 'winter4': 4}

        >>> e=b.values()

        >>> print(e)

        dict_values([1, 2, None, 4])

         """

        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 

    

   class dict

   

    

  七、集合set的命令汇总 set内无重复数据。 

  

   

   

    

    #!/usr/bin/env python

# -*- coding:utf-8 -*-

 

 

 

class set(object):

    """

    set() -> new empty set object

    set(iterable) -> new set object

 

    Build an unordered collection of unique elements.

    """

 

    def add(self, *args, **kwargs):  # real signature unknown

        """

        Add an element to a set.

 

        This has no effect if the element is already present.

        """

        pass

 

    def clear(self, *args, **kwargs):  # real signature unknown

        """ Remove all elements from this set. """

        pass

 

    def copy(self, *args, **kwargs):  # real signature unknown

        """ Return a shallow copy of a set. """

        pass

 

    def difference(self, *args, **kwargs):  # real signature unknown

        """

        Return the difference of two or more sets as a new set.

 

        (i.e. all elements that are in this set but not the others.)

        >>> a=set(['winter','winter2','winter3','winter'])

        >>> print(a)

        {'winter2', 'winter3', 'winter'}

        >>> b=set(['winter','winter2','winter3','winter4'])

        >>> c=a.difference(b)

        >>> print(c)

        set()

        >>> print(a)

        {'winter2', 'winter3', 'winter'}

        >>> print(b)

        {'winter2', 'winter4', 'winter3', 'winter'}

        >>> c=b.difference(a)

        >>> print(c)

        {'winter4'}

        

        """

        pass

 

    def difference_update(self, *args, **kwargs):  # real signature unknown

        """ Remove all elements of another set from this set. 

        删除当前set中在所有包含在new set里面的元素。

        >>> c=b.difference_update(a)

        >>> print(c)

        None

        >>> print(b)

        {'winter4'}

        >>> print(a)

        {'winter2', 'winter3', 'winter'}

        

        """

        pass

 

    def discard(self, *args, **kwargs):  # real signature unknown

        """

        Remove an element from a set if it is a member.

 

        If the element is not a member, do nothing.

        移除元素

        

        """

        pass

 

    def intersection(self, *args, **kwargs):  # real signature unknown

        """

        Return the intersection of two sets as a new set.

 

        (i.e. all elements that are in both sets.)

        取交集

        >>> c=a.intersection(b)

        >>> print(a)

        {'winter2', 'winter3', 'winter'}

        >>> print(b)

        {'winter2', 'winter4', 'winter3', 'winter'}

        >>> print(c)

        {'winter2', 'winter3', 'winter'}

        """

        pass

 

    def intersection_update(self, *args, **kwargs):  # real signature unknown

        """ Update a set with the intersection of itself and another.

         与different_update的结构类似,修改原值。

         """

        pass

 

    def isdisjoint(self, *args, **kwargs):  # real signature unknown

        """ Return True if two sets have a null intersection. 

        如果没有交集返回True

        """

        pass

 

    def issubset(self, *args, **kwargs):  # real signature unknown

        """ Report whether another set contains this set. 

        是否子集

        """

        pass

 

    def issuperset(self, *args, **kwargs):  # real signature unknown

        """ Report whether this set contains another set. 

        是否父集

        """

        pass

 

    def pop(self, *args, **kwargs):  # real signature unknown

        """

        Remove and return an arbitrary set element.

        Raises KeyError if the set is empty.

        >>> b

        {'winter2', 'winter4', 'winter3', 'winter'}

        >>> e=b.pop()

        >>> e

        'winter2'

        

        """

        pass

 

    def remove(self, *args, **kwargs):  # real signature unknown

        """

        Remove an element from a set; it must be a member.

 

        If the element is not a member, raise a KeyError.

        >>> b.remove()

        Traceback (most recent call last):

          File "<pyshell#35>", line 1, in <module>

            b.remove()

        TypeError: remove() takes exactly one argument (0 given)

        >>> b

        {'winter3', 'winter'}

        >>> b.remove('winter')

        >>> b

        {'winter3'}

        

        """

        pass

 

    def symmetric_difference(self, *args, **kwargs):  # real signature unknown

        """

        Return the symmetric difference of two sets as a new set.

 

        (i.e. all elements that are in exactly one of the sets.)

        求2个集合里面的相互之间差集和,带返回

        >>> s1=set([1,2,3])

        >>> s2=set([2,3,4])

        >>> c1=s1.symmetric_difference(s2)

        >>> c1

        {1, 4}

        >>> c2=s2.symmetric_difference(s1)

        >>> c2

        {1, 4}

 

        

        """

        pass

 

    def symmetric_difference_update(self, *args, **kwargs):  # real signature unknown

        """ Update a set with the symmetric difference of itself and another.

         求差集,不带返回

         """

        pass

 

    def union(self, *args, **kwargs):  # real signature unknown

        """

        Return the union of sets as a new set.

 

        (i.e. all elements that are in either set.)

        并集

        """

        pass

 

    def update(self, *args, **kwargs):  # real signature unknown

        """ Update a set with the union of itself and others.

        特别注意,and和update的不同。

        >>> b

        {'winter3'}

        >>> b

        {'winter3'}

        >>> b.update('winter')

        >>> b

        {'t', 'r', 'w', 'winter3', 'i', 'e', 'n'}

        >>> b.add('winter')

        >>> b

        {'t', 'r', 'winter', 'w', 'winter3', 'i', 'e', 'n'}

        >>> 

         """

        pass

 

    def __and__(self, *args, **kwargs):  # real signature unknown

        """ Return self&value.

         不知道用途,

         补充关于and 和 & 运算

         a,b分别是整数1和2,以二进制表示分别为:01,10。

        &运算结果的二进制为:00,即十进制的 0(按位逻辑运算)。再如 :2&3,二进制表示为 10&11,所以结果是 10,即十进制的 2。

        1 是真,2是真(整数0是否),所以 1 and 2 是真, 0 and 2 是否。

         

        >>> a={11111}

        >>> type(a)

        <class 'set'>

        >>> b={111111}

        >>> c=a.__and__(b)

        >>> print(c)

        set()

 

         """

        pass

 

    def __contains__(self, y):  # real signature unknown; restored from __doc__

        """ x.__contains__(y) <==> y in x.

        判断条件不明,慎用慎用。

        

         >>> a.__contains__(b)

        False

        >>> b.__contains__(a)

        False

        >>> a

        {11111}

        >>> b

        {111111}

        >>> c={1,2}

        >>> type(c)

        <class 'set'>

        >>> d={1}

        >>> c.__c

        c.__class__(    c.__contains__(

        >>> c.__contains__(d)

        False

        >>> d.__contains__(c)

        False

 

         

         """

        pass

 

    def __eq__(self, *args, **kwargs):  # real signature unknown

        """ Return self==value.

        判断是否相等

         >>> e={1}

        >>> e

        {1}

        >>> d

        {1}

        >>> e.__eq__(d)

        True

 

         """

        pass

 

    def __getattribute__(self, *args, **kwargs):  # real signature unknown

        """ Return getattr(self, name). """

        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 __iand__(self, *args, **kwargs):  # real signature unknown

        """ Return self&=value. """

        pass

 

    def __init__(self, seq=()):  # known special case of set.__init__

        """

        set() -> new empty set object

        set(iterable) -> new set object

 

        Build an unordered collection of unique elements.

        # (copied from class doc)

        """

        pass

 

    def __ior__(self, *args, **kwargs):  # real signature unknown

        """ Return self|=value. """

        pass

 

    def __isub__(self, *args, **kwargs):  # real signature unknown

        """ Return self-=value. """

        pass

 

    def __iter__(self, *args, **kwargs):  # real signature unknown

        """ Implement iter(self). """

        pass

 

    def __ixor__(self, *args, **kwargs):  # real signature unknown

        """ Return self^=value. """

        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 __or__(self, *args, **kwargs):  # real signature unknown

        """ Return self|value.

         | 或是位运算

         """

        pass

 

    def __rand__(self, *args, **kwargs):  # real signature unknown

        """ Return value&self. """

        pass

 

    def __reduce__(self, *args, **kwargs):  # real signature unknown

        """ Return state information for pickling. 

        测试在报错,不知道原因

        >>> a.__reduce_()

            Traceback (most recent call last):

              File "<stdin>", line 1, in <module>

            AttributeError: 'set' object has no attribute '__reduce_'

    

        

        """

        pass

 

    def __repr__(self, *args, **kwargs):  # real signature unknown

        """ Return repr(self). """

        pass

 

    def __ror__(self, *args, **kwargs):  # real signature unknown

        """ Return value|self. """

        pass

 

    def __rsub__(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):  # real signature unknown; restored from __doc__

        """ S.__sizeof__() -> size of S in memory, in bytes 

        返回S在内存占用的大小

        """

        pass

 

    def __sub__(self, *args, **kwargs):  # real signature unknown

        """ Return self-value. """

        pass

 

    def __xor__(self, *args, **kwargs):  # real signature unknown

        """ Return self^value. """

        pass

 

    __hash__ = None 

    

   class set

   

    

    

  其他 

  

   1、for循环

   

  

   用户按照顺序循环可迭代对象中的内容,

   

  

   PS:break、continue

   

   

   

    

    

     

     li=[11,22,33,44,55,66]

for item in li:

    print (item)

 

#-------------结果----------------

11

22

33

44

55

66 

     

    for

    

     

   

    2、range

    

   

    指定范围,生成指定的数字

    

   

     

    

    

    

     

     

      

      a=[]

b=[]

c=[]

d=[]

for i in range(1,10):

    a.append(i)

 

for i in range(1,10,2):

    b.append(i)

 

for i in range(30,0,-1):

    c.append(i)

 

for i in range(60,10,-2):

    d.append(i)

 

print(a)

print(b)

print(c)

print(d)

 

#----------------结果-----------------------------------

[1, 2, 3, 4, 5, 6, 7, 8, 9]

[1, 3, 5, 7, 9]

[30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]

[60, 58, 56, 54, 52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12] 

      

     range

     

      

    

   

  

   3、enumrate

   

  

   为可迭代的对象添加序号

   

   

   

    

    

     

     a=[]

b=[]

c=[]

d=[]

for k,v in enumerate(range(1,10),1):

    a.append(k)

    b.append(v)

 

 

for k,v in enumerate(range(30,0,-1),10):

    c.append(k)

    d.append(v)

 

print(a)

print(b)

print(c)

print(d)

 

li=[11,22,33,44]

for k,v in enumerate(li,20):

    print(k,v)

for k,v in enumerate(li,-5):

    print(k,v)

 

#-----------------结果----------------------------------

[1, 2, 3, 4, 5, 6, 7, 8, 9]

[1, 2, 3, 4, 5, 6, 7, 8, 9]

[10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39]

[30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]

20 11

21 22

22 33

23 44

-5 11

-4 22

-3 33

-2 44 

     

    enumrate

    

     

   

  练习题 

    

  

   二、查找

   

  

   查找列表中元素,移除每个元素的空格,并查找以 a或A开头 并且以 c 结尾的所有元素。

   

  

       li = ["alec", " aric", "Alex", "Tony", "rain"]

   

  

       tu = ("alec", " aric", "Alex", "Tony", "rain") 

   

  

       dic = {'k1': "alex", 'k2': ' aric',  "k3": "Alex", "k4": "Tony"}

   

  

    

   

  

    

   

   

   

    

    

     

     li = ["alec", " aric", "Alex", "Tony", "rain"]

tu = ("alec", " aric", "Alex", "Tony", "rain")

dic = {'k1': "alex", 'k2': ' aric', "k3": "Alex", "k4": "Tony"}

 

li1=[]

li2=[]

dic1={}

li1_onlyac=[]

li2_onlyac=[]

dic1_onlyac={}

 

for i in li:

    li1.append(i.strip())

    if i.strip().endswith('c') and i.strip().startswith('a'):

        li1_onlyac.append(i.strip())

    elif i.strip().endswith('c') and i.strip().startswith('A'):

        li1_onlyac.append(i.strip())

    else:

        continue

 

for i in tu:

    li2.append(i.strip())

    if i.strip().endswith('c') and i.strip().startswith('a'):

        li2_onlyac.append(i.strip())

    elif i.strip().endswith('c') and i.strip().startswith('A'):

        li2_onlyac.append(i.strip())

    else:

        continue

for i in dic.keys():

    dic1[i]=dic[i].strip()

    if dic[i].strip().endswith('c') and dic[i].strip().startswith('a'):

        dic1_onlyac[i] = dic[i].strip()

    elif dic[i].strip().endswith('c') and dic[i].strip().startswith('A'):

        dic1_onlyac[i] = dic[i].strip()

    else:

        continue

print(li1)

print(li2)

print(dic1)

print(li1_onlyac)

print(li2_onlyac)

print(dic1_onlyac) 

     

    练习代码

    

     

   

  

    

   

    

  

  

 

转载于:https://www.cnblogs.com/wintershen/p/6755976.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值