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

參考鏈接: Python中的Inplace運算符| 1(iadd(),isub(),iconcat()…)

運算符?

?

? 1、算數運算:

??

??

? ?

? 2、比較運算:?

? ?

? 3、賦值運算:?

? ?

? 4、邏輯運算:?

? ?

? 5、成員運算:?

? ?

? 6、三元運算?

? 三元運算(三目運算),是對簡單的條件語句的縮寫。?

? ?

? ??

? ? ?

? ? ??

? ? ? ? ?

? ? ? ? ? 1

? ? ? ? ??

? ? ? ? ?

? ? ? ? ? 2

? ? ? ? ??

? ? ? ? ?

? ? ? ? ? 3

? ? ? ? ??

? ? ? ? ?

? ? ? ? ? 4

? ? ? ? ??

? ? ? ? ?

? ? ? ? ? 5

? ? ? ? ? ?

? ? ? ? ??

? ? ? ? ??

? ? ? ? ? ?# 書寫格式

? ? ? ? ? ?

? ? ? ? ??

? ? ? ? ? ??

? ? ? ? ? ?

? ? ? ? ??

? ? ? ? ? ?result?

? ? ? ? ? ?=?

? ? ? ? ? ?值

? ? ? ? ? ?1?

? ? ? ? ? ?if?

? ? ? ? ? ?條件?

? ? ? ? ? ?else?

? ? ? ? ? ?值

? ? ? ? ? ?2

? ? ? ? ? ?

? ? ? ? ??

? ? ? ? ? ??

? ? ? ? ? ?

? ? ? ? ??

? ? ? ? ? ?# 如果條件成立,那么將 “值1” 賦值給result變量,否則,將“值2”賦值給result變量

? ? ? ? ? ?

? ? ? ? ??

? ? ?

? ??

? ?

? 基本數據類型?

??

? ?1、數字

? ?

? ?

? ?int(整型)?

? ?

? ?   在32位機器上,整數的位數為32位,取值范圍為-2**31~2**31-1,即-2147483648~2147483647

? ?   在64位系統上,整數的位數為64位,取值范圍為-2**63~2**63-1,即-9223372036854775808~9223372036854775807

? ??

? ??

? ? ?

? ? ? ?1 class int(object):

? 2? ? ?"""

? 3? ? ?int(x=0) -> int or long

? 4? ? ?int(x, base=10) -> int or long 把一個字符串轉成十進制,base指定字符串的進制,默認十進制

? 5? ? ?如:int('ffff', base=16)把16進制的字符串轉成十進制

? 6? ? ?Convert a number or string to an integer, or return 0 if no arguments

? 7? ? ?are given.? If x is floating point, the conversion truncates towards zero.

? 8? ? ?If x is outside the integer range, the function returns a long instead.

? 9? ? ?

?10? ? ?If x is not a number or if base is given, then x must be a string or

?11? ? ?Unicode object representing an integer literal in the given base.? The

?12? ? ?literal can be preceded by '+' or '-' and be surrounded by whitespace.

?13? ? ?The base defaults to 10.? Valid bases are 0 and 2-36.? Base 0 means to

?14? ? ?interpret the base from the string as an integer literal.

?15? ? ?>>> int('0b100', base=0)

?16? ? ?4

?17? ? ?"""

?18? ? ?def bit_length(self):?

?19? ? ? ? ?""" 返回表示該數字的實際占用的最少位數 """

?20? ? ? ? ?"""

?21? ? ? ? ?int.bit_length() -> int

?22? ? ? ? ?

?23? ? ? ? ?Number of bits necessary to represent self in binary.

?24? ? ? ? ?>>> bin(37)

?25? ? ? ? ?'0b100101'

?26? ? ? ? ?>>> (37).bit_length()

?27? ? ? ? ?6

?28? ? ? ? ?"""

?29? ? ? ? ?return 0

?30?

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

?32? ? ? ? ?""" 返回該復數的共軛復數 """

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

?34? ? ? ? ?pass

?35?

?36? ? ?def __abs__(self):

?37? ? ? ? ?""" 返回絕對值 """

?38? ? ? ? ?""" x.__abs__() <==> abs(x) """

?39? ? ? ? ?pass

?40?

?41? ? ?def __add__(self, y):

?42? ? ? ? ?""" x.__add__(y) <==> x+y """

?43? ? ? ? ?pass

?44?

?45? ? ?def __and__(self, y):

?46? ? ? ? ?""" x.__and__(y) <==> x&y """

?47? ? ? ? ?pass

?48?

?49? ? ?def __cmp__(self, y):?

?50? ? ? ? ?""" 比較兩個數大小 """

?51? ? ? ? ?""" x.__cmp__(y) <==> cmp(x,y) """

?52? ? ? ? ?pass

?53?

?54? ? ?def __coerce__(self, y):

?55? ? ? ? ?""" 強制生成一個元組 """?

?56? ? ? ? ?""" x.__coerce__(y) <==> coerce(x, y) """

?57? ? ? ? ?pass

?58?

?59? ? ?def __divmod__(self, y):?

?60? ? ? ? ?""" 相除,得到商和余數組成的元組 """?

?61? ? ? ? ?""" x.__divmod__(y) <==> divmod(x, y) """

?62? ? ? ? ?pass

?63?

?64? ? ?def __div__(self, y):?

?65? ? ? ? ?""" x.__div__(y) <==> x/y """

?66? ? ? ? ?pass

?67?

?68? ? ?def __float__(self):?

?69? ? ? ? ?""" 轉換為浮點類型 """?

?70? ? ? ? ?""" x.__float__() <==> float(x) """

?71? ? ? ? ?pass

?72?

?73? ? ?def __floordiv__(self, y):?

?74? ? ? ? ?""" x.__floordiv__(y) <==> x//y """

?75? ? ? ? ?pass

?76?

?77? ? ?def __format__(self, *args, **kwargs): # real signature unknown

?78? ? ? ? ?pass

?79?

?80? ? ?def __getattribute__(self, name):?

?81? ? ? ? ?""" x.__getattribute__('name') <==> x.name """

?82? ? ? ? ?pass

?83?

?84? ? ?def __getnewargs__(self, *args, **kwargs): # real signature unknown

?85? ? ? ? ?""" 內部調用 __new__方法或創建對象時傳入參數使用 """?

?86? ? ? ? ?pass

?87?

?88? ? ?def __hash__(self):?

?89? ? ? ? ?"""如果對象object為哈希表類型,返回對象object的哈希值。哈希值為整數。在字典查找中,哈希值用于快速比較字典的鍵。兩個數值如果相等,則哈希值也相等。"""

?90? ? ? ? ?""" x.__hash__() <==> hash(x) """

?91? ? ? ? ?pass

?92?

?93? ? ?def __hex__(self):?

?94? ? ? ? ?""" 返回當前數的 十六進制 表示 """?

?95? ? ? ? ?""" x.__hex__() <==> hex(x) """

?96? ? ? ? ?pass

?97?

?98? ? ?def __index__(self):?

?99? ? ? ? ?""" 用于切片,數字無意義 """

100? ? ? ? ?""" x[y:z] <==> x[y.__index__():z.__index__()] """

101? ? ? ? ?pass

102?

103? ? ?def __init__(self, x, base=10): # known special case of int.__init__

104? ? ? ? ?""" 構造方法,執行 x = 123 或 x = int(10) 時,自動調用,暫時忽略 """?

105? ? ? ? ?"""

106? ? ? ? ?int(x=0) -> int or long

107? ? ? ? ?int(x, base=10) -> int or long

108? ? ? ? ?

109? ? ? ? ?Convert a number or string to an integer, or return 0 if no arguments

110? ? ? ? ?are given.? If x is floating point, the conversion truncates towards zero.

111? ? ? ? ?If x is outside the integer range, the function returns a long instead.

112? ? ? ? ?

113? ? ? ? ?If x is not a number or if base is given, then x must be a string or

114? ? ? ? ?Unicode object representing an integer literal in the given base.? The

115? ? ? ? ?literal can be preceded by '+' or '-' and be surrounded by whitespace.

116? ? ? ? ?The base defaults to 10.? Valid bases are 0 and 2-36.? Base 0 means to

117? ? ? ? ?interpret the base from the string as an integer literal.

118? ? ? ? ?>>> int('0b100', base=0)

119? ? ? ? ?4

120? ? ? ? ?# (copied from class doc)

121? ? ? ? ?"""

122? ? ? ? ?pass

123?

124? ? ?def __int__(self):?

125? ? ? ? ?""" 轉換為整數 """?

126? ? ? ? ?""" x.__int__() <==> int(x) """

127? ? ? ? ?pass

128?

129? ? ?def __invert__(self):?

130? ? ? ? ?""" x.__invert__() <==> ~x """

131? ? ? ? ?pass

132?

133? ? ?def __long__(self):?

134? ? ? ? ?""" 轉換為長整數 """?

135? ? ? ? ?""" x.__long__() <==> long(x) """

136? ? ? ? ?pass

137?

138? ? ?def __lshift__(self, y):?

139? ? ? ? ?""" x.__lshift__(y) <==> x<<y """

140? ? ? ? ?pass

141?

142? ? ?def __mod__(self, y):?

143? ? ? ? ?""" x.__mod__(y) <==> x%y """

144? ? ? ? ?pass

145?

146? ? ?def __mul__(self, y):?

147? ? ? ? ?""" x.__mul__(y) <==> x*y """

148? ? ? ? ?pass

149?

150? ? ?def __neg__(self):?

151? ? ? ? ?""" x.__neg__() <==> -x """

152? ? ? ? ?pass

153?

154? ? ?@staticmethod # known case of __new__

155? ? ?def __new__(S, *more):?

156? ? ? ? ?""" T.__new__(S, ...) -> a new object with type S, a subtype of T """

157? ? ? ? ?pass

158?

159? ? ?def __nonzero__(self):?

160? ? ? ? ?""" x.__nonzero__() <==> x != 0 """

161? ? ? ? ?pass

162?

163? ? ?def __oct__(self):?

164? ? ? ? ?""" 返回改值的 八進制 表示 """?

165? ? ? ? ?""" x.__oct__() <==> oct(x) """

166? ? ? ? ?pass

167?

168? ? ?def __or__(self, y):?

169? ? ? ? ?""" x.__or__(y) <==> x|y """

170? ? ? ? ?pass

171?

172? ? ?def __pos__(self):?

173? ? ? ? ?""" x.__pos__() <==> +x """

174? ? ? ? ?pass

175?

176? ? ?def __pow__(self, y, z=None):?

177? ? ? ? ?""" 冪,次方 """?

178? ? ? ? ?""" x.__pow__(y[, z]) <==> pow(x, y[, z]) """

179? ? ? ? ?pass

180?

181? ? ?def __radd__(self, y):?

182? ? ? ? ?""" x.__radd__(y) <==> y+x """

183? ? ? ? ?pass

184?

185? ? ?def __rand__(self, y):?

186? ? ? ? ?""" x.__rand__(y) <==> y&x """

187? ? ? ? ?pass

188?

189? ? ?def __rdivmod__(self, y):?

190? ? ? ? ?""" x.__rdivmod__(y) <==> divmod(y, x) """

191? ? ? ? ?pass

192?

193? ? ?def __rdiv__(self, y):?

194? ? ? ? ?""" x.__rdiv__(y) <==> y/x """

195? ? ? ? ?pass

196?

197? ? ?def __repr__(self):?

198? ? ? ? ?"""轉化為解釋器可讀取的形式 """

199? ? ? ? ?""" x.__repr__() <==> repr(x) """

200? ? ? ? ?pass

201?

202? ? ?def __str__(self):?

203? ? ? ? ?"""轉換為人閱讀的形式,如果沒有適于人閱讀的解釋形式的話,則返回解釋器課閱讀的形式"""

204? ? ? ? ?""" x.__str__() <==> str(x) """

205? ? ? ? ?pass

206?

207? ? ?def __rfloordiv__(self, y):?

208? ? ? ? ?""" x.__rfloordiv__(y) <==> y//x """

209? ? ? ? ?pass

210?

211? ? ?def __rlshift__(self, y):?

212? ? ? ? ?""" x.__rlshift__(y) <==> y<<x """

213? ? ? ? ?pass

214?

215? ? ?def __rmod__(self, y):?

216? ? ? ? ?""" x.__rmod__(y) <==> y%x """

217? ? ? ? ?pass

218?

219? ? ?def __rmul__(self, y):?

220? ? ? ? ?""" x.__rmul__(y) <==> y*x """

221? ? ? ? ?pass

222?

223? ? ?def __ror__(self, y):?

224? ? ? ? ?""" x.__ror__(y) <==> y|x """

225? ? ? ? ?pass

226?

227? ? ?def __rpow__(self, x, z=None):?

228? ? ? ? ?""" y.__rpow__(x[, z]) <==> pow(x, y[, z]) """

229? ? ? ? ?pass

230?

231? ? ?def __rrshift__(self, y):?

232? ? ? ? ?""" x.__rrshift__(y) <==> y>>x """

233? ? ? ? ?pass

234?

235? ? ?def __rshift__(self, y):?

236? ? ? ? ?""" x.__rshift__(y) <==> x>>y """

237? ? ? ? ?pass

238?

239? ? ?def __rsub__(self, y):?

240? ? ? ? ?""" x.__rsub__(y) <==> y-x """

241? ? ? ? ?pass

242?

243? ? ?def __rtruediv__(self, y):?

244? ? ? ? ?""" x.__rtruediv__(y) <==> y/x """

245? ? ? ? ?pass

246?

247? ? ?def __rxor__(self, y):?

248? ? ? ? ?""" x.__rxor__(y) <==> y^x """

249? ? ? ? ?pass

250?

251? ? ?def __sub__(self, y):?

252? ? ? ? ?""" x.__sub__(y) <==> x-y """

253? ? ? ? ?pass

254?

255? ? ?def __truediv__(self, y):?

256? ? ? ? ?""" x.__truediv__(y) <==> x/y """

257? ? ? ? ?pass

258?

259? ? ?def __trunc__(self, *args, **kwargs):?

260? ? ? ? ?""" 返回數值被截取為整形的值,在整形中無意義 """

261? ? ? ? ?pass

262?

263? ? ?def __xor__(self, y):?

264? ? ? ? ?""" x.__xor__(y) <==> x^y """

265? ? ? ? ?pass

266?

267? ? ?denominator = property(lambda self: object(), lambda self, v: None, lambda self: None)? # default

268? ? ?""" 分母 = 1 """

269? ? ?"""the denominator of a rational number in lowest terms"""

270?

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

272? ? ?""" 虛數,無意義 """

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

274?

275? ? ?numerator = property(lambda self: object(), lambda self, v: None, lambda self: None)? # default

276? ? ?""" 分子 = 數字大小 """

277? ? ?"""the numerator of a rational number in lowest terms"""

278?

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

280? ? ?""" 實屬,無意義 """

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

? ? ?

? ? ??

? ??

? ? ?2、布爾值

? ? ?

? ??

? ? ?  True? False

? ? ?

? ??

? ? ? ? ? ? ?""、None、()、[]、{}、0? ? ?==》假

? ? ?

? ??

? ? ? ? ? ? ?" " 、其它? ? ? ? ? ? ? ? ? ? ? ? ? ?==》真

? ? ?

? ??

? ? ??

? ? ?3、字符串

? ? ?

? ? ?

? ? ?

? ? ? "hello world"

? ? ??

? ? ?

? ??

? ? ?字符串常用功能:

? ? ?

? ? ?

? ? ?移除空白分割長度索引切片

? ? ??

? ? ? ? 1? ?class str(object):

? 2? ? ?"""

? 3? ? ?str(object='') -> str

? 4? ? ?str(bytes_or_buffer[, encoding[, errors]]) -> str

? 5? ? ?

? 6? ? ?Create a new string object from the given object. If encoding or

? 7? ? ?errors is specified, then the object must expose a data buffer

? 8? ? ?that will be decoded using the given encoding and error handler.

? 9? ? ?Otherwise, returns the result of object.__str__() (if defined)

?10? ? ?or repr(object).

?11? ? ?encoding defaults to sys.getdefaultencoding().

?12? ? ?errors defaults to 'strict'.

?13? ? ?"""

?14? ? ?def capitalize(self): # real signature unknown; restored from __doc__

?15? ? ? ? ?""" 首字母變大寫 """

?16? ? ? ? ?"""

?17? ? ? ? ?S.capitalize() -> str

?18? ? ? ? ?

?19? ? ? ? ?Return a capitalized version of S, i.e. make the first character

?20? ? ? ? ?have upper case and the rest lower case.

?21? ? ? ? ?"""

?22? ? ? ? ?return ""

?23?

?24? ? ?def casefold(self): # real signature unknown; restored from __doc__

?25? ? ? ? ?""" 多國語言大寫變小寫{漢字大寫就轉不成小寫} """

?26? ? ? ? ?"""

?27? ? ? ? ?S.casefold() -> str

?28? ? ? ? ?

?29? ? ? ? ?Return a version of S suitable for caseless comparisons.

?30? ? ? ? ?"""

?31? ? ? ? ?return ""

?32?

?33? ? ?def center(self, width, fillchar=None): # real signature unknown; restored from __doc__

?34? ? ? ? ?""" 內容居中,width:總長度;fillchar:空白處填充內容,默認無 """

?35? ? ? ? ?"""

?36? ? ? ? ?S.center(width[, fillchar]) -> str

?37? ? ? ? ?

?38? ? ? ? ?Return S centered in a string of length width. Padding is

?39? ? ? ? ?done using the specified fill character (default is a space)

?40? ? ? ? ?"""

?41? ? ? ? ?return ""

?42?

?43? ? ?def count(self, sub, start=None, end=None): # real signature unknown; restored from __doc__

?44? ? ? ? ?""" 子序列個數 """

?45? ? ? ? ?"""

?46? ? ? ? ?S.count(sub[, start[, end]]) -> int

?47? ? ? ? ?

?48? ? ? ? ?Return the number of non-overlapping occurrences of substring sub in

?49? ? ? ? ?string S[start:end].? Optional arguments start and end are

?50? ? ? ? ?interpreted as in slice notation.

?51? ? ? ? ?"""

?52? ? ? ? ?return 0

?53?

?54? ? ?def encode(self, encoding='utf-8', errors='strict'): # real signature unknown; restored from __doc__

?55? ? ? ? ?"""

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

?57? ? ? ? ?

?58? ? ? ? ?Encode S using the codec registered for encoding. Default encoding

?59? ? ? ? ?is 'utf-8'. errors may be given to set a different error

?60? ? ? ? ?handling scheme. Default is 'strict' meaning that encoding errors raise

?61? ? ? ? ?a UnicodeEncodeError. Other possible values are 'ignore', 'replace' and

?62? ? ? ? ?'xmlcharrefreplace' as well as any other name registered with

?63? ? ? ? ?codecs.register_error that can handle UnicodeEncodeErrors.

?64? ? ? ? ?"""

?65? ? ? ? ?return b""

?66?

?67? ? ?def endswith(self, suffix, start=None, end=None): # real signature unknown; restored from __doc__

?68? ? ? ? ?""" 是否以 xxx 結束 """

?69? ? ? ? ?"""

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

?71? ? ? ? ?

?72? ? ? ? ?Return True if S ends with the specified suffix, False otherwise.

?73? ? ? ? ?With optional start, test S beginning at that position.

?74? ? ? ? ?With optional end, stop comparing S at that position.

?75? ? ? ? ?suffix can also be a tuple of strings to try.

?76? ? ? ? ?"""

?77? ? ? ? ?return False

?78?

?79? ? ?def expandtabs(self, tabsize=8): # real signature unknown; restored from __doc__

?80? ? ? ? ?"""?

?81? ? ? ? ?將tab轉換成空格{以4個為一組斷開,如果出現tab,就讓空格把其它的補齊},默認一個tab轉換成8個空格

?82? ? ? ? ? 如:s = '123ddd\terere\t';

?83? ? ? ? ? ? ? ? ? print(s.expandtabs(4))

?84? ? ? ? ? ? ? ? ? 結果:123ddd? erere? ?{這里,123d一組,dd+兩個空格一組,erer一組,e+三個空格一組}

?85? ? ? ? ?"""

?86? ? ? ? ?"""

?87? ? ? ? ?S.expandtabs(tabsize=8) -> str

?88? ? ? ? ?

?89? ? ? ? ?Return a copy of S where all tab characters are expanded using spaces.

?90? ? ? ? ?If tabsize is not given, a tab size of 8 characters is assumed.

?91? ? ? ? ?"""

?92? ? ? ? ?return ""

?93?

?94? ? ?def find(self, sub, start=None, end=None): # real signature unknown; restored from __doc__

?95? ? ? ? ?""" 尋找子序列位置,如果沒找到,返回 -1 """

?96? ? ? ? ?"""

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

?98? ? ? ? ?

?99? ? ? ? ?Return the lowest index in S where substring sub is found,

100? ? ? ? ?such that sub is contained within S[start:end].? Optional

101? ? ? ? ?arguments start and end are interpreted as in slice notation.

102? ? ? ? ?

103? ? ? ? ?Return -1 on failure.

104? ? ? ? ?"""

105? ? ? ? ?return 0

106?

107? ? ?def format(self, *args, **kwargs): # known special case of str.format

108? ? ? ? ?"""

109? ? ? ? ?格式化,將一個字符串中的占位符替換為指定的值

110? ? ? ? ?如:1) s = 'i am {name}';

111? ? ? ? ? ? ? ? ? ? ? print(s.format(name='jqbai'))

112? ? ? ? ? ? ? ? ? ? ? 結果:i am jqbai

113? ? ? ? ? ? ? ? ?2) s = 'i am {0}';

114? ? ? ? ? ? ? ? ? ? ? print(s.format('jqbai'))

115? ? ? ? ? ? ? ? ? ? ? 結果:i am jqbai

116? ? ? ? ?"""

117? ? ? ? ?"""

118? ? ? ? ?S.format(*args, **kwargs) -> str

119? ? ? ? ?

120? ? ? ? ?Return a formatted version of S, using substitutions from args and kwargs.

121? ? ? ? ?The substitutions are identified by braces ('{' and '}').

122? ? ? ? ?"""

123? ? ? ? ?pass

124?

125? ? ?def format_map(self, mapping): # real signature unknown; restored from __doc__

126? ? ? ? ? """

127? ? ? ? ?格式化,將一個字符串中的占位符替換為指定的值,傳入的值是{'name':'jqbai','age':'20'}

128? ? ? ? ?如:1) s = 'i am {name}, age {age}';

129? ? ? ? ? ? ? ? ? ? ? (s.format_map({'name':'jqbai','age':'20'}))

130? ? ? ? ? ? ? ? ? ? ? 結果:i am jqbai, age 20

131? ? ? ? ? ? ? ? ?2) s = 'i am {0}';

132? ? ? ? ? ? ? ? ? ? ? print(s.format('jqbai'))

133? ? ? ? ? ? ? ? ? ? ? 結果:i am jqbai

134? ? ? ? ?"""

135? ? ? ? ?"""

136? ? ? ? ?S.format_map(mapping) -> str

137? ? ? ? ?

138? ? ? ? ?Return a formatted version of S, using substitutions from mapping.

139? ? ? ? ?The substitutions are identified by braces ('{' and '}').

140? ? ? ? ?"""

141? ? ? ? ?return ""

142?

143? ? ?def index(self, sub, start=None, end=None): # real signature unknown; restored from __doc__

144? ? ? ? ?""" 尋找子序列位置,如果沒找到,報錯 """

145? ? ? ? ?"""

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

147? ? ? ? ?

148? ? ? ? ?Return the lowest index in S where substring sub is found,?

149? ? ? ? ?such that sub is contained within S[start:end].? Optional

150? ? ? ? ?arguments start and end are interpreted as in slice notation.

151? ? ? ? ?

152? ? ? ? ?Raises ValueError when the substring is not found.

153? ? ? ? ?"""

154? ? ? ? ?return 0

155?

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

157? ? ? ? ?""" 是否是字母、數字和漢字 """

158? ? ? ? ?"""

159? ? ? ? ?S.isalnum() -> bool

160? ? ? ? ?

161? ? ? ? ?Return True if all characters in S are alphanumeric

162? ? ? ? ?and there is at least one character in S, False otherwise.

163? ? ? ? ?"""

164? ? ? ? ?return False

165?

166? ? ?def isalpha(self): # real signature unknown; restored from __doc__

167? ? ? ? ?""" 是否是字母和漢字 """

168? ? ? ? ?"""

169? ? ? ? ?S.isalpha() -> bool

170? ? ? ? ?

171? ? ? ? ?Return True if all characters in S are alphabetic

172? ? ? ? ?and there is at least one character in S, False otherwise.

173? ? ? ? ?"""

174? ? ? ? ?return False

175?

176? ? ?def isdecimal(self): # real signature unknown; restored from __doc__

177? ? ? ? ?""" 是否是數字{只能是阿拉伯數字} """

178? ? ? ? ?"""

179? ? ? ? ?S.isdecimal() -> bool

180? ? ? ? ?

181? ? ? ? ?Return True if there are only decimal characters in S,

182? ? ? ? ?False otherwise.

183? ? ? ? ?"""

184? ? ? ? ?return False

185?

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

187? ? ? ? ?""" 是否是數字{可以是特殊的數字如:②{二:這種不行}} """

188? ? ? ? ?"""

189? ? ? ? ?S.isdigit() -> bool

190? ? ? ? ?

191? ? ? ? ?Return True if all characters in S are digits

192? ? ? ? ?and there is at least one character in S, False otherwise.

193? ? ? ? ?"""

194? ? ? ? ?return False

195?

196? ? ?def isidentifier(self): # real signature unknown; restored from __doc__

197? ? ? ? ?""" 是否是標識符,標識符只能用字母,數字,下劃線的命名,但是不能以數字開頭 """

198? ? ? ? ?"""

199? ? ? ? ?S.isidentifier() -> bool

200? ? ? ? ?

201? ? ? ? ?Return True if S is a valid identifier according

202? ? ? ? ?to the language definition.

203? ? ? ? ?

204? ? ? ? ?Use keyword.iskeyword() to test for reserved identifiers

205? ? ? ? ?such as "def" and "class".

206? ? ? ? ?"""

207? ? ? ? ?return False

208?

209? ? ?def islower(self): # real signature unknown; restored from __doc__

210? ? ? ? ?""" 是否都是小寫 """

211? ? ? ? ?"""

212? ? ? ? ?S.islower() -> bool

213? ? ? ? ?

214? ? ? ? ?Return True if all cased characters in S are lowercase and there is

215? ? ? ? ?at least one cased character in S, False otherwise.

216? ? ? ? ?"""

217? ? ? ? ?return False

218?

219? ? ?def isnumeric(self): # real signature unknown; restored from __doc__

220? ? ? ? ?""" 是否是數字{可以是特殊的數字如:②,二 """

221? ? ? ? ?"""

222? ? ? ? ?S.isnumeric() -> bool

223? ? ? ? ?

224? ? ? ? ?Return True if there are only numeric characters in S,

225? ? ? ? ?False otherwise.

226? ? ? ? ?"""

227? ? ? ? ?return False

228?

229? ? ?def isprintable(self): # real signature unknown; restored from __doc__

230? ? ? ? ?""" 是否都是可見的,如果存在轉義字符(如:\n、\t等)則返回False """

231? ? ? ? ?"""

232? ? ? ? ?S.isprintable() -> bool

233? ? ? ? ?

234? ? ? ? ?Return True if all characters in S are considered

235? ? ? ? ?printable in repr() or S is empty, False otherwise.

236? ? ? ? ?"""

237? ? ? ? ?return False

238?

239? ? ?def isspace(self): # real signature unknown; restored from __doc__

240? ? ? ? ?""" 是否是空格 """

241? ? ? ? ?"""

242? ? ? ? ?S.isspace() -> bool

243? ? ? ? ?

244? ? ? ? ?Return True if all characters in S are whitespace

245? ? ? ? ?and there is at least one character in S, False otherwise.

246? ? ? ? ?"""

247? ? ? ? ?return False

248?

249? ? ?def istitle(self): # real signature unknown; restored from __doc__

250? ? ? ? ?""" 是否是標題,標題是一段單詞的首字母都是大寫,如:My Family """

251? ? ? ? ?"""

252? ? ? ? ?S.istitle() -> bool

253? ? ? ? ?

254? ? ? ? ?Return True if S is a titlecased string and there is at least one

255? ? ? ? ?character in S, i.e. upper- and titlecase characters may only

256? ? ? ? ?follow uncased characters and lowercase characters only cased ones.

257? ? ? ? ?Return False otherwise.

258? ? ? ? ?"""

259? ? ? ? ?return False

260?

261? ? ?def isupper(self): # real signature unknown; restored from __doc__

262? ? ? ? ?""" 是否都是大寫 """

263? ? ? ? ?"""

264? ? ? ? ?S.isupper() -> bool

265? ? ? ? ?

266? ? ? ? ?Return True if all cased characters in S are uppercase and there is

267? ? ? ? ?at least one cased character in S, False otherwise.

268? ? ? ? ?"""

269? ? ? ? ?return False

270?

271? ? ?def join(self, iterable): # real signature unknown; restored from __doc__

272? ? ? ? ?"""?

273? ? ? ? ?連接:

274? ? ? ? ? ? ?如:seq = '我愛祖國'

275? ? ? ? ? ? ? ? ? ? ?string = ' '

276? ? ? ? ? ? ? ? ? ? ?print(string.join(seq))

277? ? ? ? ? ? ? ? ? ? ?結果:我 愛 祖 國

278? ? ? ? ? ? ? ? ? ? ?以 string 作為分隔符,將 seq 中所有的元素(的字符串表示)合并為一個新的字符串

279? ? ? ? ?"""

280? ? ? ? ?"""

281? ? ? ? ?S.join(iterable) -> str

282? ? ? ? ?

283? ? ? ? ?Return a string which is the concatenation of the strings in the

284? ? ? ? ?iterable.? The separator between elements is S.

285? ? ? ? ?"""

286? ? ? ? ?return ""

287?

288? ? ?def ljust(self, width, fillchar=None): # real signature unknown; restored from __doc__

289? ? ? ? ?""" 內容左對齊,右側填充 """

290? ? ? ? ?"""

291? ? ? ? ?S.ljust(width[, fillchar]) -> str

292? ? ? ? ?

293? ? ? ? ?Return S left-justified in a Unicode string of length width. Padding is

294? ? ? ? ?done using the specified fill character (default is a space).

295? ? ? ? ?"""

296? ? ? ? ?return ""

297?

298? ? ?def lower(self): # real signature unknown; restored from __doc__

299? ? ? ? ?""" 變小寫 """

300? ? ? ? ?"""

301? ? ? ? ?S.lower() -> str

302? ? ? ? ?

303? ? ? ? ?Return a copy of the string S converted to lowercase.

304? ? ? ? ?"""

305? ? ? ? ?return ""

306?

307? ? ?def lstrip(self, chars=None): # real signature unknown; restored from __doc__

308? ? ? ? ? """ 移除左側指定的字符

309? ? ? ? ? ? ? 如:seq = 'adcb'

310? ? ? ? ? ? ? ? ? ? ? print(seq.rstrip('labc'))

311? ? ? ? ? ? ? ? ? ? ? 則結果為:dcb

312? ? ? ? ? ? ? ?{默認去除的是空格<\t,\n也可以去除>}

313? ? ? ? ?"""

314? ? ? ? ?"""

315? ? ? ? ?S.lstrip([chars]) -> str

316? ? ? ? ?

317? ? ? ? ?Return a copy of the string S with leading whitespace removed.

318? ? ? ? ?If chars is given and not None, remove characters in chars instead.

319? ? ? ? ?"""

320? ? ? ? ?return ""

321?

322? ? ?def maketrans(self, *args, **kwargs): # real signature unknown

323? ? ? ? ?"""

324? ? ? ? ?str.maketrans('abc','123')

325? ? ? ? ?print('sacbd'.translate(str.maketrans('abc','123')))

326? ? ? ? ?結果:s132d

327? ? ? ? ?"""

328? ? ? ? ?"""

329? ? ? ? ?Return a translation table usable for str.translate().

330? ? ? ? ?

331? ? ? ? ?If there is only one argument, it must be a dictionary mapping Unicode

332? ? ? ? ?ordinals (integers) or characters to Unicode ordinals, strings or None.

333? ? ? ? ?Character keys will be then converted to ordinals.

334? ? ? ? ?If there are two arguments, they must be strings of equal length, and

335? ? ? ? ?in the resulting dictionary, each character in x will be mapped to the

336? ? ? ? ?character at the same position in y. If there is a third argument, it

337? ? ? ? ?must be a string, whose characters will be mapped to None in the result.

338? ? ? ? ?"""

339? ? ? ? ?pass

340?

341? ? ?def partition(self, sep): # real signature unknown; restored from __doc__

342? ? ? ? ?"""

343? ? ? ? ?從左分割,前,中,后三部分

344? ? ? ? ?如:print('adbdbs'.partition('d'))

345? ? ? ? ? ? ? ? ?結果為:('a', 'd', 'bdbs')

346? ? ? ? ?""

347? ? ? ? ?"""

348? ? ? ? ?S.partition(sep) -> (head, sep, tail)

349? ? ? ? ?

350? ? ? ? ?Search for the separator sep in S, and return the part before it,

351? ? ? ? ?the separator itself, and the part after it.? If the separator is not

352? ? ? ? ?found, return S and two empty strings.

353? ? ? ? ?"""

354? ? ? ? ?pass

355?

356? ? ?def replace(self, old, new, count=None): # real signature unknown; restored from __doc__

357? ? ? ? ?""" 替換 """

358? ? ? ? ?"""

359? ? ? ? ?S.replace(old, new[, count]) -> str

360? ? ? ? ?

361? ? ? ? ?Return a copy of S with all occurrences of substring

362? ? ? ? ?old replaced by new.? If the optional argument count is

363? ? ? ? ?given, only the first count occurrences are replaced.

364? ? ? ? ?"""

365? ? ? ? ?return ""

366?

367? ? ?def rfind(self, sub, start=None, end=None): # real signature unknown; restored from __doc__

368? ? ? ? ?"""

369? ? ? ? ?S.rfind(sub[, start[, end]]) -> int

370? ? ? ? ?

371? ? ? ? ?Return the highest index in S where substring sub is found,

372? ? ? ? ?such that sub is contained within S[start:end].? Optional

373? ? ? ? ?arguments start and end are interpreted as in slice notation.

374? ? ? ? ?

375? ? ? ? ?Return -1 on failure.

376? ? ? ? ?"""

377? ? ? ? ?return 0

378?

379? ? ?def rindex(self, sub, start=None, end=None): # real signature unknown; restored from __doc__

380? ? ? ? ?"""

381? ? ? ? ?S.rindex(sub[, start[, end]]) -> int

382? ? ? ? ?

383? ? ? ? ?Return the highest index in S where substring sub is found,

384? ? ? ? ?such that sub is contained within S[start:end].? Optional

385? ? ? ? ?arguments start and end are interpreted as in slice notation.

386? ? ? ? ?

387? ? ? ? ?Raises ValueError when the substring is not found.

388? ? ? ? ?"""

389? ? ? ? ?return 0

390?

391? ? ?def rjust(self, width, fillchar=None): # real signature unknown; restored from __doc__

392? ? ? ? ?""" 內容右對齊,左側填充 """

393? ? ? ? ?"""

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

395? ? ? ? ?

396? ? ? ? ?Return S right-justified in a string of length width. Padding is

397? ? ? ? ?done using the specified fill character (default is a space).

398? ? ? ? ?"""

399? ? ? ? ?return ""

400?

401? ? ?def rpartition(self, sep): # real signature unknown; restored from __doc__

402? ? ? ? ?"""

403? ? ? ? ?從右分割,前,中,后三部分

404? ? ? ? ?如:print('adbdbs'.partition('d'))

405? ? ? ? ? ? ? ? ?結果為:('adb', 'd', 'bs')

406? ? ? ? ?""

407? ? ? ? ?"""

408? ? ? ? ?S.rpartition(sep) -> (head, sep, tail)

409? ? ? ? ?

410? ? ? ? ?Search for the separator sep in S, starting at the end of S, and return

411? ? ? ? ?the part before it, the separator itself, and the part after it.? If the

412? ? ? ? ?separator is not found, return two empty strings and S.

413? ? ? ? ?"""

414? ? ? ? ?pass

415?

416? ? ?def rsplit(self, sep=None, maxsplit=-1): # real signature unknown; restored from __doc__

417? ? ? ? ?""" 從右到左分割, maxsplit最多分割幾次 """

418? ? ? ? ?"""

419? ? ? ? ?S.rsplit(sep=None, maxsplit=-1) -> list of strings

420? ? ? ? ?

421? ? ? ? ?Return a list of the words in S, using sep as the

422? ? ? ? ?delimiter string, starting at the end of the string and

423? ? ? ? ?working to the front.? If maxsplit is given, at most maxsplit

424? ? ? ? ?splits are done. If sep is not specified, any whitespace string

425? ? ? ? ?is a separator.

426? ? ? ? ?"""

427? ? ? ? ?return []

428?

429? ? ?def rstrip(self, chars=None): # real signature unknown; restored from __doc__

430? ? ? ? ?""" 移除右側指定的字符

431? ? ? ? ? ? ? 如:seq = 'adcb'

432? ? ? ? ? ? ? ? ? ? ? print(seq.rstrip('labc'))

433? ? ? ? ? ? ? ? ? ? ? 則結果為:ad

434? ? ? ? ? ? ? ?{默認去除的是空格<\t,\n也可以去除>}

435? ? ? ? ?"""

436? ? ? ? ?"""

437? ? ? ? ?S.rstrip([chars]) -> str

438? ? ? ? ?

439? ? ? ? ?Return a copy of the string S with trailing whitespace removed.

440? ? ? ? ?If chars is given and not None, remove characters in chars instead.

441? ? ? ? ?"""

442? ? ? ? ?return ""

443?

444? ? ?def split(self, sep=None, maxsplit=-1): # real signature unknown; restored from __doc__

445? ? ? ? ?""" 從左到右分割, maxsplit最多分割幾次 """

446? ? ? ? ?"""

447? ? ? ? ?S.split(sep=None, maxsplit=-1) -> list of strings

448? ? ? ? ?

449? ? ? ? ?Return a list of the words in S, using sep as the

450? ? ? ? ?delimiter string.? If maxsplit is given, at most maxsplit

451? ? ? ? ?splits are done. If sep is not specified or is None, any

452? ? ? ? ?whitespace string is a separator and empty strings are

453? ? ? ? ?removed from the result.

454? ? ? ? ?"""

455? ? ? ? ?return []

456?

457? ? ?def splitlines(self, keepends=None): # real signature unknown; restored from __doc__

458? ? ? ? ?"""?

459? ? ? ? ?根據換行分割, keepends=True保留換號符(\n) keepends=False不保留換行符,默認 keepends=False

460? ? ? ? 如:print('ad\nb\ndbs'.splitlines(True))

461? ? ? ? ? ? ? ? 結果:['ad\n', 'b\n', 'dbs']

462? ? ? ? """

463? ? ? ? ?"""

464? ? ? ? ?S.splitlines([keepends]) -> list of strings

465? ? ? ? ?

466? ? ? ? ?Return a list of the lines in S, breaking at line boundaries.

467? ? ? ? ?Line breaks are not included in the resulting list unless keepends

468? ? ? ? ?is given and true.

469? ? ? ? ?"""

470? ? ? ? ?return []

471?

472? ? ?def startswith(self, prefix, start=None, end=None): # real signature unknown; restored from __doc__

473? ? ? ? ?""" 是否以xxx起始 """

474? ? ? ? ?"""

475? ? ? ? ?S.startswith(prefix[, start[, end]]) -> bool

476? ? ? ? ?

477? ? ? ? ?Return True if S starts with the specified prefix, False otherwise.

478? ? ? ? ?With optional start, test S beginning at that position.

479? ? ? ? ?With optional end, stop comparing S at that position.

480? ? ? ? ?prefix can also be a tuple of strings to try.

481? ? ? ? ?"""

482? ? ? ? ?return False

483?

484? ? ?def strip(self, chars=None): # real signature unknown; restored from __doc__

485? ? ? ? ? """ 移除左側指定的字符

486? ? ? ? ? ? ? 如:seq = 'adcb'

487? ? ? ? ? ? ? ? ? ? ? print(seq.rstrip('labc'))

488? ? ? ? ? ? ? ? ? ? ? 則結果為:dcb

489? ? ? ? ? ? ? ?{默認去除的是空格<\t,\n也可以去除>}

490? ? ? ? ?"""

491? ? ? ? ?"""

492? ? ? ? ?S.strip([chars]) -> str

493? ? ? ? ?

494? ? ? ? ?Return a copy of the string S with leading and trailing

495? ? ? ? ?whitespace removed.

496? ? ? ? ?If chars is given and not None, remove characters in chars instead.

497? ? ? ? ?"""

498? ? ? ? ?return ""

499?

500? ? ?def swapcase(self): # real signature unknown; restored from __doc__

501? ? ? ? ?""" 大寫變小寫,小寫變大寫 """

502? ? ? ? ?"""

503? ? ? ? ?S.swapcase() -> str

504? ? ? ? ?

505? ? ? ? ?Return a copy of S with uppercase characters converted to lowercase

506? ? ? ? ?and vice versa.

507? ? ? ? ?"""

508? ? ? ? ?return ""

509?

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

511? ? ? ? ?""" 把一段單詞變成標題,如:my family變成My Family """

512? ? ? ? ?"""

513? ? ? ? ?S.title() -> str

514? ? ? ? ?

515? ? ? ? ?Return a titlecased version of S, i.e. words start with title case

516? ? ? ? ?characters, all remaining cased characters have lower case.

517? ? ? ? ?"""

518? ? ? ? ?return ""

519?

520? ? ?def translate(self, table): # real signature unknown; restored from __doc__

521? ? ? ? ?"""

522? ? ? ? ?str.maketrans('abc','123')

523? ? ? ? ?print('sacbd'.translate(str.maketrans('abc','123')))

524? ? ? ? ?結果:s132d

525? ? ? ? ?"""

526? ? ? ? ?"""

527? ? ? ? ?S.translate(table) -> str

528? ? ? ? ?

529? ? ? ? ?Return a copy of the string S in which each character has been mapped

530? ? ? ? ?through the given translation table. The table must implement

531? ? ? ? ?lookup/indexing via __getitem__, for instance a dictionary or list,

532? ? ? ? ?mapping Unicode ordinals to Unicode ordinals, strings, or None. If

533? ? ? ? ?this operation raises LookupError, the character is left untouched.

534? ? ? ? ?Characters mapped to None are deleted.

535? ? ? ? ?"""

536? ? ? ? ?return ""

537?

538? ? ?def upper(self): # real signature unknown; restored from __doc__

539? ? ? ? ?"""

540? ? ? ? ?S.upper() -> str

541? ? ? ? ?

542? ? ? ? ?Return a copy of S converted to uppercase.

543? ? ? ? ?"""

544? ? ? ? ?return ""

545?

546? ? ?def zfill(self, width): # real signature unknown; restored from __doc__

547? ? ? ? ?"""方法返回指定長度的字符串,原字符串右對齊,前面填充0。"""

548? ? ? ? ?"""

549? ? ? ? ?S.zfill(width) -> str

550? ? ? ? ?

551? ? ? ? ?Pad a numeric string S with zeros on the left, to fill a field

552? ? ? ? ?of the specified width. The string S is never truncated.

553? ? ? ? ?"""

554? ? ? ? ?return ""

555?

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

557? ? ? ? ?""" Return self+value. """

558? ? ? ? ?pass

559?

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

561? ? ? ? ?""" Return key in self. """

562? ? ? ? ?pass

563?

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

565? ? ? ? ?""" Return self==value. """

566? ? ? ? ?pass

567?

568? ? ?def __format__(self, format_spec): # real signature unknown; restored from __doc__

569? ? ? ? ?"""

570? ? ? ? ?S.__format__(format_spec) -> str

571? ? ? ? ?

572? ? ? ? ?Return a formatted version of S as described by format_spec.

573? ? ? ? ?"""

574? ? ? ? ?return ""

575?

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

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

578? ? ? ? ?pass

579?

580? ? ?def __getitem__(self, *args, **kwargs): # real signature unknown

581? ? ? ? ?""" Return self[key]. """

582? ? ? ? ?pass

583?

584? ? ?def __getnewargs__(self, *args, **kwargs): # real signature unknown

585? ? ? ? ?pass

586?

587? ? ?def __ge__(self, *args, **kwargs): # real signature unknown

588? ? ? ? ?""" Return self>=value. """

589? ? ? ? ?pass

590?

591? ? ?def __gt__(self, *args, **kwargs): # real signature unknown

592? ? ? ? ?""" Return self>value. """

593? ? ? ? ?pass

594?

595? ? ?def __hash__(self, *args, **kwargs): # real signature unknown

596? ? ? ? ?""" Return hash(self). """

597? ? ? ? ?pass

598?

599? ? ?def __init__(self, value='', encoding=None, errors='strict'): # known special case of str.__init__

600? ? ? ? ?"""

601? ? ? ? ?str(object='') -> str

602? ? ? ? ?str(bytes_or_buffer[, encoding[, errors]]) -> str

603? ? ? ? ?

604? ? ? ? ?Create a new string object from the given object. If encoding or

605? ? ? ? ?errors is specified, then the object must expose a data buffer

606? ? ? ? ?that will be decoded using the given encoding and error handler.

607? ? ? ? ?Otherwise, returns the result of object.__str__() (if defined)

608? ? ? ? ?or repr(object).

609? ? ? ? ?encoding defaults to sys.getdefaultencoding().

610? ? ? ? ?errors defaults to 'strict'.

611? ? ? ? ?# (copied from class doc)

612? ? ? ? ?"""

613? ? ? ? ?pass

614?

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

616? ? ? ? ?""" Implement iter(self). """

617? ? ? ? ?pass

618?

619? ? ?def __len__(self, *args, **kwargs): # real signature unknown

620? ? ? ? ?""" Return len(self). """

621? ? ? ? ?pass

622?

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

624? ? ? ? ?""" Return self<=value. """

625? ? ? ? ?pass

626?

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

628? ? ? ? ?""" Return self<value. """

629? ? ? ? ?pass

630?

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

632? ? ? ? ?""" Return self%value. """

633? ? ? ? ?pass

634?

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

636? ? ? ? ?""" Return self*value.n """

637? ? ? ? ?pass

638?

639? ? ?@staticmethod # known case of __new__

640? ? ?def __new__(*args, **kwargs): # real signature unknown

641? ? ? ? ?""" Create and return a new object.? See help(type) for accurate signature. """

642? ? ? ? ?pass

643?

644? ? ?def __ne__(self, *args, **kwargs): # real signature unknown

645? ? ? ? ?""" Return self!=value. """

646? ? ? ? ?pass

647?

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

649? ? ? ? ?""" Return repr(self). """

650? ? ? ? ?pass

651?

652? ? ?def __rmod__(self, *args, **kwargs): # real signature unknown

653? ? ? ? ?""" Return value%self. """

654? ? ? ? ?pass

655?

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

657? ? ? ? ?""" Return self*value. """

658? ? ? ? ?pass

659?

660? ? ?def __sizeof__(self): # real signature unknown; restored from __doc__

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

662? ? ? ? ?pass

663?

664? ? ?def __str__(self, *args, **kwargs): # real signature unknown

665? ? ? ? ?""" Return str(self). """

666? ? ? ? ?pass? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?

? ? ??

? ? ? ?

? ? ?

? ??

? ??

? ? ??

? ??

? ? ?4、列表

? ? ?

? ??

? ? ?創建列表:

? ? ?

? ? ?

? ? ??

? ? ? ?

? ? ? ??

? ? ? ? ?

? ? ? ? ? ??

? ? ? ? ? ? ?1

? ? ? ? ? ? ?

? ? ? ? ? ??

? ? ? ? ? ? ?2

? ? ? ? ? ? ?

? ? ? ? ? ??

? ? ? ? ? ? ?3

? ? ? ? ? ? ??

? ? ? ? ? ? ?

? ? ? ? ? ? ?

? ? ? ? ? ? ? name_list?

? ? ? ? ? ? ? =?

? ? ? ? ? ? ? [

? ? ? ? ? ? ? 'alex'

? ? ? ? ? ? ? ,?

? ? ? ? ? ? ? 'seven'

? ? ? ? ? ? ? ,?

? ? ? ? ? ? ? 'eric'

? ? ? ? ? ? ? ]

? ? ? ? ? ? ??

? ? ? ? ? ? ?

? ? ? ? ? ? ? 或

? ? ? ? ? ? ??

? ? ? ? ? ? ?

? ? ? ? ? ? ? name_list =?

? ? ? ? ? ? ? list

? ? ? ? ? ? ? ([

? ? ? ? ? ? ? 'alex'

? ? ? ? ? ? ? ,?

? ? ? ? ? ? ? 'seven'

? ? ? ? ? ? ? ,?

? ? ? ? ? ? ? 'eric'

? ? ? ? ? ? ? ])

? ? ? ? ? ? ??

? ? ? ? ? ? ?

? ? ? ??

? ? ? ?

? ? ??

? ? ??

? ? ? 基本操作:?

? ? ? 索引切片追加刪除長度切片循環包含 列表轉換字符串,如果列表內都是字符串,直接join就OK,如果有數字,則需要自己for循環,然后把數字轉出字符串,在加起來?

? ? ? ?

? ? ? ?class list(object):

? ? """

? ? list() -> new empty list

? ? list(iterable) -> new list initialized from iterable's items

? ? """

? ? def append(self, p_object): # real signature unknown; restored from __doc__

? ? ? ? """ 追加:給列表追加一個元素 """

? ? ? ? """ L.append(object) -> None -- append object to end """

? ? ? ? pass

?

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

? ? ? ? """ 清空列表 """

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

? ? ? ? pass

?

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

? ? ? ? """ 拷貝列表(淺拷貝) """

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

? ? ? ? return []

?

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

? ? ? ? """ 計算元素出現的次數:指定元素在列表中出現幾次 """

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

? ? ? ? return 0

?

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

? ? ? ? """ 擴展原來的列表:參數是可迭代對象,如:字符串,列表 """

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

? ? ? ? pass

?

? ? def index(self, value, start=None, stop=None): # real signature unknown; restored from __doc__

? ? ? ? """ 從左往右找,找指定元素的下標(若相同元素有多個,返回第一個元素的下標) """

? ? ? ? """

? ? ? ? L.index(value, [start, [stop]]) -> integer -- return first index of value.

? ? ? ? Raises ValueError if the value is not present.

? ? ? ? """

? ? ? ? return 0

?

? ? def insert(self, index, p_object): # real signature unknown; restored from __doc__

? ? ? ? """ 給指定位置插入一個元素 """

? ? ? ? """ L.insert(index, object) -- insert object before index """

? ? ? ? pass

?

? ? def pop(self, index=None): # real signature unknown; restored from __doc__

? ? ? ? """ 刪除某個下標位置的值,默認刪除最后一個,返回刪除的那個值 """

? ? ? ? """

? ? ? ? L.pop([index]) -> item -- remove and return item at index (default last).

? ? ? ? Raises IndexError if list is empty or index is out of range.

? ? ? ? """

? ? ? ? pass

?

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

? ? ? ? """

? ? ? ? 刪除指定元素的值,使用del也可以刪除,如:del li[1],或者del li[1:4]

? ? ? ? """

? ? ? ? """

? ? ? ? L.remove(value) -> None -- remove first occurrence of value.

? ? ? ? Raises ValueError if the value is not present.

? ? ? ? """

? ? ? ? pass

?

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

? ? ? ? """ 將當前列表進行反轉 """

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

? ? ? ? pass

?

? ? def sort(self, key=None, reverse=False): # real signature unknown; restored from __doc__

? ? ? ? """ 排序,默認從小到大,當reverse=True從大到小排序 """

? ? ? ? """ L.sort(key=None, reverse=False) -> None -- stable sort *IN PLACE* """

? ? ? ? pass

?

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

? ? ? ? """ Return self+value. """

? ? ? ? pass

?

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

? ? ? ? """ Return key in self. """

? ? ? ? pass

?

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

? ? ? ? """ Delete self[key]. """

? ? ? ? pass

?

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

? ? ? ? """ Return self==value. """

? ? ? ? pass

?

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

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

? ? ? ? pass

?

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

? ? ? ? """ x.__getitem__(y) <==> x[y] """

? ? ? ? pass

?

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

? ? ? ? """ Return self>=value. """

? ? ? ? pass

?

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

? ? ? ? """ Return self>value. """

? ? ? ? pass

?

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

? ? ? ? """ Implement self+=value. """

? ? ? ? pass

?

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

? ? ? ? """ Implement self*=value. """

? ? ? ? pass

?

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

? ? ? ? """

? ? ? ? list() -> new empty list

? ? ? ? list(iterable) -> new list initialized from iterable's items

? ? ? ? # (copied from class doc)

? ? ? ? """

? ? ? ? pass

?

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

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

? ? ? ? pass

?

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

? ? ? ? """ Return len(self). """

? ? ? ? pass

?

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

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

? ? ? ? pass

?

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

? ? ? ? """ Return self<value. """

? ? ? ? pass

?

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

? ? ? ? """ Return self*value.n """

? ? ? ? pass

?

? ? @staticmethod # known case of __new__

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

? ? ? ? """ Create and return a new object.? See help(type) for accurate signature. """

? ? ? ? pass

?

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

? ? ? ? """ Return self!=value. """

? ? ? ? pass

?

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

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

? ? ? ? pass

?

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

? ? ? ? """ L.__reversed__() -- return a reverse iterator over the list """

? ? ? ? pass

?

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

? ? ? ? """ Return self*value. """

? ? ? ? pass

?

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

? ? ? ? """ Set self[key] to value. """

? ? ? ? pass

?

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

? ? ? ? """ L.__sizeof__() -- size of L in memory, in bytes """

? ? ? ? pass

?

? ? __hash__ = None?

? ? ? ?

? ? ??

? ? ? ??

? ? ? ?

? ? ??

? ? ? ?5、元祖

? ? ? ?

? ? ??

? ? ? ?創建元祖:

? ? ? ?

? ? ? ?

? ? ? ??

? ? ? ? ?

? ? ? ? ??

? ? ? ? ? ?

? ? ? ? ? ? ??

? ? ? ? ? ? ? ?1

? ? ? ? ? ? ? ?

? ? ? ? ? ? ??

? ? ? ? ? ? ? ?2

? ? ? ? ? ? ? ?

? ? ? ? ? ? ??

? ? ? ? ? ? ? ?3

? ? ? ? ? ? ? ??

? ? ? ? ? ? ? ?

? ? ? ? ? ? ? ?

? ? ? ? ? ? ? ? ages?

? ? ? ? ? ? ? ? =?

? ? ? ? ? ? ? ? (

? ? ? ? ? ? ? ? 11

? ? ? ? ? ? ? ? ,?

? ? ? ? ? ? ? ? 22

? ? ? ? ? ? ? ? ,?

? ? ? ? ? ? ? ? 33

? ? ? ? ? ? ? ? ,?

? ? ? ? ? ? ? ? 44

? ? ? ? ? ? ? ? ,?

? ? ? ? ? ? ? ? 55

? ? ? ? ? ? ? ? )

? ? ? ? ? ? ? ??

? ? ? ? ? ? ? ?

? ? ? ? ? ? ? ? 或

? ? ? ? ? ? ? ??

? ? ? ? ? ? ? ?

? ? ? ? ? ? ? ? ages?

? ? ? ? ? ? ? ? =?

? ? ? ? ? ? ? ? tuple

? ? ? ? ? ? ? ? ((

? ? ? ? ? ? ? ? 11

? ? ? ? ? ? ? ? ,?

? ? ? ? ? ? ? ? 22

? ? ? ? ? ? ? ? ,?

? ? ? ? ? ? ? ? 33

? ? ? ? ? ? ? ? ,?

? ? ? ? ? ? ? ? 44

? ? ? ? ? ? ? ? ,?

? ? ? ? ? ? ? ? 55

? ? ? ? ? ? ? ? ))

? ? ? ? ? ? ? ??

? ? ? ? ? ? ? ?

? ? ? ? ??

? ? ? ? ?

? ? ? ??

? ? ? ?

? ? ? ? 基本操作(元組的一級元素不可變):

? ? ? ??

? ? ? ??

? ? ? ? 索引切片循環長度包含創建元組的時候后面加個逗號,用以區分方法和元素,如:(1,3,)

? ? ? ??

? ? ? ?

? ? ??

? ? ?

? ??

? ?

??

??

? ?

? ?class tuple(object):

? ? """

? ? tuple() -> empty tuple

? ? tuple(iterable) -> tuple initialized from iterable's items

? ??

? ? If the argument is a tuple, the return value is the same object.

? ? """

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

? ? ? ?""" 統計指定元素出現的次數 """

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

? ? ? ? return 0

?

? ? def index(self, value, start=None, stop=None): # real signature unknown; restored from __doc__

? ? ? ? """ 獲取指定元素在元組中的下標 """

? ? ? ? """

? ? ? ? T.index(value, [start, [stop]]) -> integer -- return first index of value.

? ? ? ? Raises ValueError if the value is not present.

? ? ? ? """

? ? ? ? return 0

?

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

? ? ? ? """ Return self+value. """

? ? ? ? pass

?

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

? ? ? ? """ Return key in self. """

? ? ? ? pass

?

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

? ? ? ? """ Return self==value. """

? ? ? ? pass

?

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

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

? ? ? ? pass

?

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

? ? ? ? """ Return self[key]. """

? ? ? ? pass

?

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

? ? ? ? pass

?

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

? ? ? ? """ Return self>=value. """

? ? ? ? pass

?

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

? ? ? ? """ Return self>value. """

? ? ? ? pass

?

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

? ? ? ? """ Return hash(self). """

? ? ? ? pass

?

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

? ? ? ? """

? ? ? ? tuple() -> empty tuple

? ? ? ? tuple(iterable) -> tuple initialized from iterable's items

? ? ? ??

? ? ? ? If the argument is a tuple, the return value is the same object.

? ? ? ? # (copied from class doc)

? ? ? ? """

? ? ? ? pass

?

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

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

? ? ? ? pass

?

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

? ? ? ? """ Return len(self). """

? ? ? ? pass

?

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

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

? ? ? ? pass

?

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

? ? ? ? """ Return self<value. """

? ? ? ? pass

?

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

? ? ? ? """ Return self*value.n """

? ? ? ? pass

?

? ? @staticmethod # known case of __new__

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

? ? ? ? """ Create and return a new object.? See help(type) for accurate signature. """

? ? ? ? pass

?

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

? ? ? ? """ Return self!=value. """

? ? ? ? pass

?

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

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

? ? ? ? pass

?

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

? ? ? ? """ Return self*value. """

? ? ? ? pass?

? ?

? ??

??

? ?6、字典(無序)

? ?

??

? ?創建字典:

? ?

? ?

? ??

? ? ?

? ? ??

? ? ? ?

? ? ? ? ??

? ? ? ? ? ?1

? ? ? ? ? ?

? ? ? ? ??

? ? ? ? ? ?2

? ? ? ? ? ?

? ? ? ? ??

? ? ? ? ? ?3

? ? ? ? ? ??

? ? ? ? ? ?

? ? ? ? ? ?

? ? ? ? ? ? person?

? ? ? ? ? ? =?

? ? ? ? ? ? {

? ? ? ? ? ? "name"

? ? ? ? ? ? :?

? ? ? ? ? ? "mr.wu"

? ? ? ? ? ? ,?

? ? ? ? ? ? 'age'

? ? ? ? ? ? :?

? ? ? ? ? ? 18

? ? ? ? ? ? }

? ? ? ? ? ??

? ? ? ? ? ?

? ? ? ? ? ? 或

? ? ? ? ? ??

? ? ? ? ? ?

? ? ? ? ? ? person?

? ? ? ? ? ? =?

? ? ? ? ? ? dict

? ? ? ? ? ? ({

? ? ? ? ? ? "name"

? ? ? ? ? ? :?

? ? ? ? ? ? "mr.wu"

? ? ? ? ? ? ,?

? ? ? ? ? ? 'age'

? ? ? ? ? ? :?

? ? ? ? ? ? 18

? ? ? ? ? ? })

? ? ? ? ? ??

? ? ? ? ? ?

? ? ??

? ? ?

? ??

? ??

? ? 常用操作:?

? ? 索引新增刪除鍵、值、鍵值對循環長度數字,字符串,元組,bool(如果是True當key,則key轉成1,False,key轉成0),可以作為字典的key 字典的for循環,默認循環所有的key?

? ? ?

? ? ?class dict(object):

? ? """

? ? dict() -> new empty dictionary

? ? dict(mapping) -> new dictionary initialized from a mapping object's

? ? ? ? (key, value) pairs

? ? dict(iterable) -> new dictionary initialized as if via:

? ? ? ? d = {}

? ? ? ? for k, v in iterable:

? ? ? ? ? ? d[k] = v

? ? dict(**kwargs) -> new dictionary initialized with the name=value pairs

? ? ? ? in the keyword argument list.? For example:? dict(one=1, two=2)

? ? """

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

? ? ? ? """ 清除內容 """

? ? ? ? """ D.clear() -> None.? Remove all items from D. """

? ? ? ? pass

?

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

? ? ? ? """ 淺拷貝 """

? ? ? ? """ D.copy() -> a shallow copy of D """

? ? ? ? pass

?

? ? @staticmethod # known case

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

? ? ? ? """

? ? ? ? 根據序列創建字典,并且指定統一的值(最多只能傳兩個序列)

? ? ? ? 如:dict.fromkeys(['a','b','c']) 創建的字典為:{'a': None, 'b': None, 'c': None}

? ? ? ? ? ? ? ? dict.fromkeys(['a','b','c'],['a','b','c']) 創建的字典為:{'a': 'a', 'b': 'b', 'c': 'c'}??

? ? ? ? """

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

? ? ? ? pass

?

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

? ? ? ? """ 根據key獲取值,通過索引去值得時候,若key不存在,出錯 """??

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

? ? ? ? pass

?

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

? ? ? ? """

? ? ? ? 獲取所有元素

? ? ? ? 如:info = {"a" : "a","b","b"}

? ? ? ? ? ? ? ? for k, v in info.items():

? ? ? ? """

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

? ? ? ? pass

?

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

? ? ? ? "" 獲取所有的key """

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

? ? ? ? pass

?

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

? ? ? ? """ 獲取并在字典中移除,返回移除的key對應的value,如果key不存在,則返回d,d默認空,可指定值 """

? ? ? ? """

? ? ? ? D.pop(k[,d]) -> v, remove specified key and return the corresponding value.

? ? ? ? If key is not found, d is returned if given, otherwise KeyError is raised

? ? ? ? """

? ? ? ? pass

?

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

? ? ? ? """ 獲取并在字典中移除(隨機移除一個),默認移除后返回的是元祖(k,v)可以用k,v = dic.popitem(),返回:k v """

? ? ? ? """

? ? ? ? D.popitem() -> (k, v), remove and return some (key, value) pair as a

? ? ? ? 2-tuple; but raise KeyError if D is empty.

? ? ? ? """

? ? ? ? pass

?

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

? ? ? ? """ 如果key不存在,則創建,如果存在,則返回已存在的值且不修改 """

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

? ? ? ? pass

?

? ? def update(self, E=None, **F): # known special case of dict.update

? ? ? ? """

? ? ? ? 存在更新key對應的value,不存在,插入一個k,y對

? ? ? ? 寫法:dic.update({'k1':'v1','k2':'v2'})或者dic.update(k1='v1',k5='v5')?

? ? ? ? """??

? ? ? ? """

? ? ? ? D.update([E, ]**F) -> None.? Update D from dict/iterable E and F.

? ? ? ? If E is present and has a .keys() method, then does:? for k in E: D[k] = E[k]

? ? ? ? If E is present and lacks a .keys() method, then does:? for k, v in E: D[k] = v

? ? ? ? In either case, this is followed by: for k in F:? D[k] = F[k]

? ? ? ? """

? ? ? ? pass

?

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

? ? ? ? """ 獲取所有的值 """

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

? ? ? ? pass

?

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

? ? ? ? """ True if D has a key k, else False. """

? ? ? ? pass

?

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

? ? ? ? """ Delete self[key]. """

? ? ? ? pass

?

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

? ? ? ? """ Return self==value. """

? ? ? ? pass

?

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

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

? ? ? ? pass

?

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

? ? ? ? """ x.__getitem__(y) <==> x[y] """

? ? ? ? pass

?

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

? ? ? ? """ Return self>=value. """

? ? ? ? pass

?

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

? ? ? ? """ Return self>value. """

? ? ? ? pass

?

? ? def __init__(self, seq=None, **kwargs): # known special case of dict.__init__

? ? ? ? """

? ? ? ? dict() -> new empty dictionary

? ? ? ? dict(mapping) -> new dictionary initialized from a mapping object's

? ? ? ? ? ? (key, value) pairs

? ? ? ? dict(iterable) -> new dictionary initialized as if via:

? ? ? ? ? ? d = {}

? ? ? ? ? ? for k, v in iterable:

? ? ? ? ? ? ? ? d[k] = v

? ? ? ? dict(**kwargs) -> new dictionary initialized with the name=value pairs

? ? ? ? ? ? in the keyword argument list.? For example:? dict(one=1, two=2)

? ? ? ? # (copied from class doc)

? ? ? ? """

? ? ? ? pass

?

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

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

? ? ? ? pass

?

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

? ? ? ? """ Return len(self). """

? ? ? ? pass

?

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

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

? ? ? ? pass

?

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

? ? ? ? """ Return self<value. """

? ? ? ? pass

?

? ? @staticmethod # known case of __new__

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

? ? ? ? """ Create and return a new object.? See help(type) for accurate signature. """

? ? ? ? pass

?

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

? ? ? ? """ Return self!=value. """

? ? ? ? pass

?

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

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

? ? ? ? pass

?

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

? ? ? ? """ Set self[key] to value. """

? ? ? ? pass

?

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

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

? ? ? ? pass

?

? ? __hash__ = None?

? ? ?

? ? ??

? ? 7、集合(無序)?

? ? set集合,是一個無序且不重復的元素集合?

? ? 使用:frozenset('hello')定義,不可變集合?

? ? 集合的元素遵循三個原則:?

? ? 1.每個元素必須是不可變類型(可hash,可作為字典的key)?

? ? 2.沒有重復的元素?

? ? 3.無序?

? ? ?

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

? ? ? ? """ 求差集同- 如:set1 - set2 """

? ? ? ? """

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

? ? ? ? """

? ? ? ? pass

?

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

? ? ? ? """ 求差集更新set1,相當于:set1 = set1 - set2 """

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

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

? ? ? ? """ 求交集用&也可以,set1 & set2 """

? ? ? ? """

? ? ? ? Return the intersection of two sets as a new set.

? ? ? ??

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

? ? ? ? """

? ? ? ? pass

?

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

? ? ? ? """ 求交集用并更新set1,相當于:set1 = set1 - set2 """

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

? ? ? ? pass

?

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

? ? ? ? """ 兩個set沒有交集,返回True """

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

? ? ? ? pass

?

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

? ? ? ? """ 是否是子集:相當于:set1 <= set2 """

? ? ? ? """ Report whether another set contains this set. """

? ? ? ? pass

?

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

? ? ? ? """ 是否是父集集:相當于:set1 >= set2 """

? ? ? ? """ Report whether this set contains another set. """

? ? ? ? pass

?

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

? ? ? ? """ 隨機刪除一個,如果set是空,則拋錯 """

? ? ? ? """

? ? ? ? Remove and return an arbitrary set element.

? ? ? ? Raises KeyError if the set is empty.

? ? ? ? """

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

? ? ? ? """

? ? ? ? pass

?

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

? ? ? ? """ 交叉補集:獲取兩個集合中不同的元素,組成的集合,同^,如:set1 ^ set2 """

? ? ? ? """

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

? ? ? ??

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

? ? ? ? """

? ? ? ? pass

?

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

? ? ? ? """ 交叉補集并更新,同^,如:set1 = set1 ^ set2 """

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

? ? ? ? pass

?

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

? ? ? ? """ 求并集同 | 如:set1 | set2 """

? ? ? ? """

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

? ? ? ? pass

?

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

? ? ? ? """ Return self&value. """

? ? ? ? pass

?

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

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

? ? ? ? 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 __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. """

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

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

? ? ?

? ? ??

? ? 其他?

? ??

? ? ?1、for循環

? ? ?

? ??

? ? ?用戶按照順序循環可迭代對象中的內容,

? ? ?

? ??

? ? ?PS:break、continue

? ? ?

? ? ?

? ? ??

? ? ? ?

? ? ? ??

? ? ? ? ?

? ? ? ? ? ??

? ? ? ? ? ? ?1

? ? ? ? ? ? ?

? ? ? ? ? ??

? ? ? ? ? ? ?2

? ? ? ? ? ? ?

? ? ? ? ? ??

? ? ? ? ? ? ?3

? ? ? ? ? ? ??

? ? ? ? ? ? ?

? ? ? ? ? ? ?

? ? ? ? ? ? ? li?

? ? ? ? ? ? ? =?

? ? ? ? ? ? ? [

? ? ? ? ? ? ? 11

? ? ? ? ? ? ? ,

? ? ? ? ? ? ? 22

? ? ? ? ? ? ? ,

? ? ? ? ? ? ? 33

? ? ? ? ? ? ? ,

? ? ? ? ? ? ? 44

? ? ? ? ? ? ? ]

? ? ? ? ? ? ??

? ? ? ? ? ? ?

? ? ? ? ? ? ? for?

? ? ? ? ? ? ? item?

? ? ? ? ? ? ? in?

? ? ? ? ? ? ? li:

? ? ? ? ? ? ??

? ? ? ? ? ? ?

? ? ? ? ? ? ? ? ??

? ? ? ? ? ? ? print?

? ? ? ? ? ? ? item

? ? ? ? ? ? ??

? ? ? ? ? ? ?

? ? ? ??

? ? ? ?

? ? ??

? ? ?

? ??

? ? ?2、enumrate

? ? ?

? ??

? ? ?為可迭代的對象添加序號

? ? ?

? ? ?

? ? ??

? ? ? ?

? ? ? ??

? ? ? ? ?

? ? ? ? ? ??

? ? ? ? ? ? ?1

? ? ? ? ? ? ?

? ? ? ? ? ??

? ? ? ? ? ? ?2

? ? ? ? ? ? ?

? ? ? ? ? ??

? ? ? ? ? ? ?3

? ? ? ? ? ? ??

? ? ? ? ? ? ?

? ? ? ? ? ? ?

? ? ? ? ? ? ? li?

? ? ? ? ? ? ? =?

? ? ? ? ? ? ? [

? ? ? ? ? ? ? 11

? ? ? ? ? ? ? ,

? ? ? ? ? ? ? 22

? ? ? ? ? ? ? ,

? ? ? ? ? ? ? 33

? ? ? ? ? ? ? ]

? ? ? ? ? ? ??

? ? ? ? ? ? ?

? ? ? ? ? ? ? for?

? ? ? ? ? ? ? k,v?

? ? ? ? ? ? ? in?

? ? ? ? ? ? ? enumerate

? ? ? ? ? ? ? (li,?

? ? ? ? ? ? ? 1

? ? ? ? ? ? ? ):

? ? ? ? ? ? ??

? ? ? ? ? ? ?

? ? ? ? ? ? ? ? ??

? ? ? ? ? ? ? print

? ? ? ? ? ? ? (k,v)

? ? ? ? ? ? ??

? ? ? ? ? ? ?

? ? ? ??

? ? ? ?

? ? ??

? ? ?

? ??

? ? ?3、range

? ? ?

? ??

? ? ?指定范圍,生成指定的數字

? ? ?

? ? ?

? ? ??

? ? ? ?

? ? ? ??

? ? ? ? ?

? ? ? ? ? ??

? ? ? ? ? ? ?1

? ? ? ? ? ? ?

? ? ? ? ? ??

? ? ? ? ? ? ?2

? ? ? ? ? ? ?

? ? ? ? ? ??

? ? ? ? ? ? ?3

? ? ? ? ? ? ?

? ? ? ? ? ??

? ? ? ? ? ? ?4

? ? ? ? ? ? ?

? ? ? ? ? ??

? ? ? ? ? ? ?5

? ? ? ? ? ? ?

? ? ? ? ? ??

? ? ? ? ? ? ?6

? ? ? ? ? ? ?

? ? ? ? ? ??

? ? ? ? ? ? ?7

? ? ? ? ? ? ?

? ? ? ? ? ??

? ? ? ? ? ? ?8

? ? ? ? ? ? ??

? ? ? ? ? ? ?

? ? ? ? ? ? ?

? ? ? ? ? ? ? print?

? ? ? ? ? ? ? range

? ? ? ? ? ? ? (

? ? ? ? ? ? ? 1

? ? ? ? ? ? ? ,?

? ? ? ? ? ? ? 10

? ? ? ? ? ? ? )

? ? ? ? ? ? ??

? ? ? ? ? ? ?

? ? ? ? ? ? ? # 結果:[1, 2, 3, 4, 5, 6, 7, 8, 9]

? ? ? ? ? ? ??

? ? ? ? ? ? ?

? ? ? ? ? ? ? ?

? ? ? ? ? ? ??

? ? ? ? ? ? ?

? ? ? ? ? ? ? print?

? ? ? ? ? ? ? range

? ? ? ? ? ? ? (

? ? ? ? ? ? ? 1

? ? ? ? ? ? ? ,?

? ? ? ? ? ? ? 10

? ? ? ? ? ? ? ,?

? ? ? ? ? ? ? 2

? ? ? ? ? ? ? )

? ? ? ? ? ? ??

? ? ? ? ? ? ?

? ? ? ? ? ? ? # 結果:[1, 3, 5, 7, 9]

? ? ? ? ? ? ??

? ? ? ? ? ? ?

? ? ? ? ? ? ? ?

? ? ? ? ? ? ??

? ? ? ? ? ? ?

? ? ? ? ? ? ? print?

? ? ? ? ? ? ? range

? ? ? ? ? ? ? (

? ? ? ? ? ? ? 30

? ? ? ? ? ? ? ,?

? ? ? ? ? ? ? 0

? ? ? ? ? ? ? ,?

? ? ? ? ? ? ? -

? ? ? ? ? ? ? 2

? ? ? ? ? ? ? )

? ? ? ? ? ? ??

? ? ? ? ? ? ?

? ? ? ? ? ? ? # 結果:[30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2]

? ? ? ? ? ? ??

? ? ? ? ? ? ?

? ? ? ??

? ? ? ?

? ? ??

? ? ?

? ??

? ?

?   ?

?

?

轉載于:https://www.cnblogs.com/jqbai/articles/8628048.html

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

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

相關文章

數據結構 基礎知識

一。邏輯結構: 是指數據對象中數據 素之間的相互關系。 其實這也是我 今后最需要關注的問題 邏輯結構分為以 四種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窗體上使用了兩個控件&…

Oracle優化器:星型轉換(Star Query Transformation )

Oracle優化器&#xff1a;星型轉換&#xff08;Star Query Transformation &#xff09;Star query是一個事實表&#xff08;fact table&#xff09;和一些維度表&#xff08;dimension&#xff09;的join。每個維度表都跟事實表通過主外鍵join&#xff0c;且每個維度表之間不j…

[轉載] python循環中break、continue 、exit() 、pass的區別

參考鏈接&#xff1a; Python中的循環和控制語句(continue, break and pass) 1、break&#xff1a;跳出循環&#xff0c;不再執行 用在while和for循環中 用來終止循環語句&#xff0c;即循環條件沒有False條件或者序列還沒被完全遞歸完&#xff0c;也會停止執行循環語句 如果…

JavaScript | 聲明數組并使用數組索引分配元素的代碼

Declare an array, assign elements by indexes and print all elements in JavaScript. 聲明一個數組&#xff0c;通過索引分配元素&#xff0c;并打印JavaScript中的所有元素。 Code: 碼&#xff1a; <html><head><script>var fruits [];fruits[0]"…

[轉載] Python入門(輸入/輸出、數據類型、條件/循環語句)

參考鏈接&#xff1a; Python中的循環技術 在介紹之前我們先來看看計算機的三個根本性基礎&#xff1a; 1.計算機是執行輸入、運算、輸出的機器 2.程序是指令和數據的集合 3.計算機的處理方式有時與人們的思維習慣不同 &#xff08;以上是引自《計算機是怎樣跑起來的》…