[轉載] 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

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/540523.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/540523.shtml
英文地址,請注明出處:http://en.pswp.cn/news/540523.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

scala bitset_Scala中的BitSet

scala bitsetScala BitSet (Scala BitSet) Set is a collection of unique elements. 集合是唯一元素的集合。 Bitset is a set of positive integers represented as a 64-bit word. 位集是一組表示為64位字的正整數。 Syntax: 句法&#xff1a; var bitset : Bitset Bits…

構建安全網絡 比格云全系云產品30天內5折購

一年之計在于春&#xff0c;每年的三、四月&#xff0c;都是個人創業最佳的起步階段&#xff0c;也是企業采購最火熱的時期。為了降低用戶的上云成本&#xff0c;讓大家能無門檻享受到優質高性能的云服務&#xff0c;比格云從3月16日起&#xff0c;將上線“充值30天內&#xff…

python中 numpy_Python中的Numpy

python中 numpyPython中的Numpy是什么&#xff1f; (What is Numpy in Python?) Numpy is an array processing package which provides high-performance multidimensional array object and utilities to work with arrays. It is a basic package for scientific computati…

[轉載] python之路《第二篇》Python基本數據類型

參考鏈接&#xff1a; Python中的Inplace運算符| 1(iadd()&#xff0c;isub()&#xff0c;iconcat()…) 運算符 1、算數運算&#xff1a; 2、比較運算&#xff1a; 3、賦值運算&#xff1a; 4、邏輯運算&#xff1a; 5、成員運算&#xff1a; 6、三元運算 三元運算&…

數據結構 基礎知識

一。邏輯結構: 是指數據對象中數據 素之間的相互關系。 其實這也是我 今后最需要關注的問題 邏輯結構分為以 四種1. 集合結構 2.線性結構 3.數形結構 4&#xff0c;圖形結構 二。物理結構&#xff1a; 1&#xff0c;順序存儲結,2 2. 鏈式存儲結構 一&#xff0c;時間復雜…

ruby 變量類中范圍_Ruby中的類

ruby 變量類中范圍Ruby類 (Ruby Classes) In the actual world, we have many objects which belong to the same category. For instance, I am working on my laptop and this laptop is one of those laptops which exist around the globe. So, this laptop is an object o…

以云計算的名義 駐云科技牽手阿里云

本文講的是以云計算的名義 駐云科技牽手阿里云一次三個公司的牽手 可能會改變無數企業的命運 2017年4月17日&#xff0c;對于很多人來說可能只是個平常的工作日&#xff0c;但是對于國內無數的企業來說卻可能是個會改變企業命運的日。駐云科技聯合國內云服務提供商阿里云及國外…

[轉載] python學習筆記

參考鏈接&#xff1a; Python | a b并不總是a a b 官網http://www.python.org/ 官網library http://docs.python.org/library/ PyPI https://pypi.python.org/pypi 中文手冊&#xff0c;適合快速入門 http://download.csdn.net/detail/xiarendeniao/4236870 py…

標志寄存器_訪問標志寄存器,并與寄存器B |交換標志寄存器F的內容 8085微處理器...

標志寄存器Problem statement: 問題陳述&#xff1a; Write an assembly language program in 8085 microprocessor to access Flag register and exchange the content of flag register F with register B. 在8085微處理器中編寫匯編語言程序以訪問標志寄存器&#xff0c;并…

瀏覽器端已支持 ES6 規范(包括 export import)

當然&#xff0c;是幾個比較優秀的瀏覽器&#xff0c;既然是優秀的瀏覽器&#xff0c;大家肯定知道是那幾款啦&#xff0c;我就不列舉了&#xff0c;我用的是 chrome。 對 script 聲明 type 為 module 后就可以享受 es6 規范所帶來的模塊快感了。 基礎語法既然是全支持&#xf…

[轉載] Python學習:Python成員運算符和身份運算符

參考鏈接&#xff1a; Python中和is運算符之間的區別 Python成員運算符 除了以上的一些運算符之外&#xff0c;Python還支持成員運算符&#xff0c;測試實例中包含了一系列的成員&#xff0c;包括字符串&#xff0c;列表或元組。 運算符 描述 實例 in 如果在指定的序列中找…

量詞邏輯量詞里面的v表示?_代理知識表示中的量詞簡介(基于人工智能)

量詞邏輯量詞里面的v表示&#xff1f;As we know that in an AI-based agent, the knowledge is represented through two types of logic: The propositional logic and the predicate logic. In the propositional logic, we have declarative sentences, and in the predica…

[轉載] Python 機器學習經典實例

參考鏈接&#xff1a; Python中的邏輯門 內容介紹 在如今這個處處以數據驅動的世界中&#xff0c;機器學習正變得越來越大眾化。它已經被廣泛地應用于不同領域&#xff0c;如搜索引擎、機器人、無人駕駛汽車等。本書首先通過實用的案例介紹機器學習的基礎知識&#xff0c;然后…

哈希表的最差復雜度是n2_給定數組A []和數字X,請檢查A []中是否有對X | 使用哈希O(n)時間復雜度| 套裝1...

哈希表的最差復雜度是n2Prerequisite: 先決條件&#xff1a; Hashing data structure 散列數據結構 Problem statement: 問題陳述&#xff1a; Given an array and a sum X, fins any pair which sums to X. Expected time complexity O(n). 給定一個數組和一個和X &#xff…

一文讀懂深度學習框架下的目標檢測(附數據集)

從簡單的圖像分類到3D位置估算&#xff0c;在機器視覺領域里從來都不乏有趣的問題。其中我們最感興趣的問題之一就是目標檢測。 如同其他的機器視覺問題一樣&#xff0c;目標檢測目前為止還沒有公認最好的解決方法。在了解目標檢測之前&#xff0c;讓我們先快速地了解一下這個領…

[轉載] Python-Strings

參考鏈接&#xff1a; Python成員資格和身份運算符 &#xff5c; in, not in, is, is not Strings 介紹 String是Python中最常用的類型。僅僅用引號括起字符就可以創建string變量。字符串使用單引號或雙引號對Python來說是一樣的。 var1 Hello World! var2 "Pyth…

aes-128算法加密_加密算法問題-人工智能中的一種約束滿意問題

aes-128算法加密The Crypt-Arithmetic problem in Artificial Intelligence is a type of encryption problem in which the written message in an alphabetical form which is easily readable and understandable is converted into a numeric form which is neither easily…

讀書筆記《集體智慧編程》Chapter 2 : Make Recommendations

本章概要本章主要介紹了兩種協同過濾&#xff08;Collaborative Filtering&#xff09;算法&#xff0c;用于個性化推薦&#xff1a;基于用戶的協同過濾&#xff08;User-Based Collaborative Filtering&#xff0c;又稱 K-Nearest Neighbor Collaborative Filtering&#xff0…

[轉載] python中的for循環對象和循環退出

參考鏈接&#xff1a; Python中循環 流程控制-if條件 判斷條件&#xff0c;1位true&#xff0c;0是flesh&#xff0c;成立時true&#xff0c;不成立flesh&#xff0c;not取反 if 1; print hello python print true not取反&#xff0c;匹配取反&#xff0c;表示取非1…

設計一個應用程序,以在C#中的按鈕單擊事件上在MessageBox中顯示TextBox中的文本...

Here, we took two controls on windows form that are TextBox and Button, named txtInput and btnShow respectively. We have to write C# code to display TextBox’s text in the MessageBox on Button Click. 在這里&#xff0c;我們在Windows窗體上使用了兩個控件&…