日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > python >内容正文

python

[转载] python之路《第二篇》Python基本数据类型

發(fā)布時間:2025/3/11 python 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 [转载] python之路《第二篇》Python基本数据类型 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

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

運算符?

?

? 1、算數(shù)運算:

??

??

? ?

? 2、比較運算:?

? ?

? 3、賦值運算:?

? ?

? 4、邏輯運算:?

? ?

? 5、成員運算:?

? ?

? 6、三元運算?

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

? ?

? ??

? ? ?

? ? ??

? ? ? ? ?

? ? ? ? ? 1

? ? ? ? ??

? ? ? ? ?

? ? ? ? ? 2

? ? ? ? ??

? ? ? ? ?

? ? ? ? ? 3

? ? ? ? ??

? ? ? ? ?

? ? ? ? ? 4

? ? ? ? ??

? ? ? ? ?

? ? ? ? ? 5

? ? ? ? ? ?

? ? ? ? ??

? ? ? ? ??

? ? ? ? ? ?# 書寫格式

? ? ? ? ? ?

? ? ? ? ??

? ? ? ? ? ??

? ? ? ? ? ?

? ? ? ? ??

? ? ? ? ? ?result?

? ? ? ? ? ?=?

? ? ? ? ? ?值

? ? ? ? ? ?1?

? ? ? ? ? ?if?

? ? ? ? ? ?條件?

? ? ? ? ? ?else?

? ? ? ? ? ?值

? ? ? ? ? ?2

? ? ? ? ? ?

? ? ? ? ??

? ? ? ? ? ??

? ? ? ? ? ?

? ? ? ? ??

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

? ? ? ? ? ?

? ? ? ? ??

? ? ?

? ??

? ?

? 基本數(shù)據(jù)類型?

??

? ?1、數(shù)字

? ?

? ?

? ?int(整型)?

? ?

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

? ?   在64位系統(tǒng)上,整數(shù)的位數(shù)為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 把一個字符串轉(zhuǎn)成十進(jìn)制,base指定字符串的進(jìn)制,默認(rèn)十進(jìn)制

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

? 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? ? ? ? ?""" 返回表示該數(shù)字的實際占用的最少位數(shù) """

?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? ? ? ? ?""" 返回該復(fù)數(shù)的共軛復(fù)數(shù) """

?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? ? ? ? ?""" 比較兩個數(shù)大小 """

?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? ? ? ? ?""" 相除,得到商和余數(shù)組成的元組 """?

?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? ? ? ? ?""" 轉(zhuǎn)換為浮點類型 """?

?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? ? ? ? ?""" 內(nèi)部調(diào)用 __new__方法或創(chuàng)建對象時傳入?yún)?shù)使用 """?

?86? ? ? ? ?pass

?87?

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

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

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

?91? ? ? ? ?pass

?92?

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

?94? ? ? ? ?""" 返回當(dāng)前數(shù)的 十六進(jìn)制 表示 """?

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

?96? ? ? ? ?pass

?97?

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

?99? ? ? ? ?""" 用于切片,數(shù)字無意義 """

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? ? ? ? ?""" 構(gòu)造方法,執(zhí)行 x = 123 或 x = int(10) 時,自動調(diào)用,暫時忽略 """?

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? ? ? ? ?""" 轉(zhuǎn)換為整數(shù) """?

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

127? ? ? ? ?pass

128?

129? ? ?def __invert__(self):?

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

131? ? ? ? ?pass

132?

133? ? ?def __long__(self):?

134? ? ? ? ?""" 轉(zhuǎn)換為長整數(shù) """?

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? ? ? ? ?""" 返回改值的 八進(jìn)制 表示 """?

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? ? ? ? ?"""轉(zhuǎn)化為解釋器可讀取的形式 """

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

200? ? ? ? ?pass

201?

202? ? ?def __str__(self):?

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

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? ? ? ? ?""" 返回數(shù)值被截取為整形的值,在整形中無意義 """

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? ? ?""" 虛數(shù),無意義 """

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

274?

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

276? ? ?""" 分子 = 數(shù)字大小 """

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? ? ? ? ?""" 多國語言大寫變小寫{漢字大寫就轉(zhuǎn)不成小寫} """

?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? ? ? ? ?""" 內(nèi)容居中,width:總長度;fillchar:空白處填充內(nèi)容,默認(rèn)無 """

?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? ? ? ? ?""" 子序列個數(shù) """

?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 結(jié)束 """

?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轉(zhuǎn)換成空格{以4個為一組斷開,如果出現(xiàn)tab,就讓空格把其它的補齊},默認(rèn)一個tab轉(zhuǎn)換成8個空格

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

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

?84? ? ? ? ? ? ? ? ? 結(jié)果: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? ? ? ? ? ? ? ? ? ? ? 結(jié)果:i am jqbai

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

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

115? ? ? ? ? ? ? ? ? ? ? 結(jié)果: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? ? ? ? ? ? ? ? ? ? ? 結(jié)果:i am jqbai, age 20

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

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

133? ? ? ? ? ? ? ? ? ? ? 結(jié)果: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? ? ? ? ?""" 是否是字母、數(shù)字和漢字 """

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? ? ? ? ?""" 是否是數(shù)字{只能是阿拉伯?dāng)?shù)字} """

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? ? ? ? ?""" 是否是數(shù)字{可以是特殊的數(shù)字如:②{二:這種不行}} """

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? ? ? ? ?""" 是否是標(biāo)識符,標(biāo)識符只能用字母,數(shù)字,下劃線的命名,但是不能以數(shù)字開頭 """

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? ? ? ? ?""" 是否是數(shù)字{可以是特殊的數(shù)字如:②,二 """

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? ? ? ? ?""" 是否都是可見的,如果存在轉(zhuǎn)義字符(如:\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? ? ? ? ?""" 是否是標(biāo)題,標(biāo)題是一段單詞的首字母都是大寫,如: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? ? ? ? ? ? ? ? ? ? ?結(jié)果:我 愛 祖 國

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? ? ? ? ?""" 內(nèi)容左對齊,右側(cè)填充 """

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? ? ? ? ? """ 移除左側(cè)指定的字符

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

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

311? ? ? ? ? ? ? ? ? ? ? 則結(jié)果為:dcb

312? ? ? ? ? ? ? ?{默認(rèn)去除的是空格<\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? ? ? ? ?結(jié)果: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? ? ? ? ? ? ? ? ?結(jié)果為:('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? ? ? ? ?""" 內(nèi)容右對齊,左側(cè)填充 """

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? ? ? ? ? ? ? ? ?結(jié)果為:('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? ? ? ? ?""" 移除右側(cè)指定的字符

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

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

433? ? ? ? ? ? ? ? ? ? ? 則結(jié)果為:ad

434? ? ? ? ? ? ? ?{默認(rèn)去除的是空格<\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? ? ? ? ?根據(jù)換行分割, keepends=True保留換號符(\n) keepends=False不保留換行符,默認(rèn) keepends=False

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

461? ? ? ? ? ? ? ? 結(jié)果:['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? ? ? ? ? """ 移除左側(cè)指定的字符

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

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

488? ? ? ? ? ? ? ? ? ? ? 則結(jié)果為:dcb

489? ? ? ? ? ? ? ?{默認(rèn)去除的是空格<\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? ? ? ? ?""" 把一段單詞變成標(biāo)題,如: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? ? ? ? ?結(jié)果: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、列表

? ? ?

? ??

? ? ?創(chuàng)建列表:

? ? ?

? ? ?

? ? ??

? ? ? ?

? ? ? ??

? ? ? ? ?

? ? ? ? ? ??

? ? ? ? ? ? ?1

? ? ? ? ? ? ?

? ? ? ? ? ??

? ? ? ? ? ? ?2

? ? ? ? ? ? ?

? ? ? ? ? ??

? ? ? ? ? ? ?3

? ? ? ? ? ? ??

? ? ? ? ? ? ?

? ? ? ? ? ? ?

? ? ? ? ? ? ? name_list?

? ? ? ? ? ? ? =?

? ? ? ? ? ? ? [

? ? ? ? ? ? ? 'alex'

? ? ? ? ? ? ? ,?

? ? ? ? ? ? ? 'seven'

? ? ? ? ? ? ? ,?

? ? ? ? ? ? ? 'eric'

? ? ? ? ? ? ? ]

? ? ? ? ? ? ??

? ? ? ? ? ? ?

? ? ? ? ? ? ? 或

? ? ? ? ? ? ??

? ? ? ? ? ? ?

? ? ? ? ? ? ? name_list =?

? ? ? ? ? ? ? list

? ? ? ? ? ? ? ([

? ? ? ? ? ? ? 'alex'

? ? ? ? ? ? ? ,?

? ? ? ? ? ? ? 'seven'

? ? ? ? ? ? ? ,?

? ? ? ? ? ? ? 'eric'

? ? ? ? ? ? ? ])

? ? ? ? ? ? ??

? ? ? ? ? ? ?

? ? ? ??

? ? ? ?

? ? ??

? ? ??

? ? ? 基本操作:?

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

? ? ? ?

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

? ? ? ? """ 計算元素出現(xiàn)的次數(shù):指定元素在列表中出現(xiàn)幾次 """

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

? ? ? ? return 0

?

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

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

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

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

? ? ? ? """

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

? ? ? ? """ 刪除某個下標(biāo)位置的值,默認(rèn)刪除最后一個,返回刪除的那個值 """

? ? ? ? """

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

? ? ? ? """ 將當(dāng)前列表進(jìn)行反轉(zhuǎn) """

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

? ? ? ? pass

?

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

? ? ? ? """ 排序,默認(rèn)從小到大,當(dāng)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、元祖

? ? ? ?

? ? ??

? ? ? ?創(chuàng)建元祖:

? ? ? ?

? ? ? ?

? ? ? ??

? ? ? ? ?

? ? ? ? ??

? ? ? ? ? ?

? ? ? ? ? ? ??

? ? ? ? ? ? ? ?1

? ? ? ? ? ? ? ?

? ? ? ? ? ? ??

? ? ? ? ? ? ? ?2

? ? ? ? ? ? ? ?

? ? ? ? ? ? ??

? ? ? ? ? ? ? ?3

? ? ? ? ? ? ? ??

? ? ? ? ? ? ? ?

? ? ? ? ? ? ? ?

? ? ? ? ? ? ? ? ages?

? ? ? ? ? ? ? ? =?

? ? ? ? ? ? ? ? (

? ? ? ? ? ? ? ? 11

? ? ? ? ? ? ? ? ,?

? ? ? ? ? ? ? ? 22

? ? ? ? ? ? ? ? ,?

? ? ? ? ? ? ? ? 33

? ? ? ? ? ? ? ? ,?

? ? ? ? ? ? ? ? 44

? ? ? ? ? ? ? ? ,?

? ? ? ? ? ? ? ? 55

? ? ? ? ? ? ? ? )

? ? ? ? ? ? ? ??

? ? ? ? ? ? ? ?

? ? ? ? ? ? ? ? 或

? ? ? ? ? ? ? ??

? ? ? ? ? ? ? ?

? ? ? ? ? ? ? ? ages?

? ? ? ? ? ? ? ? =?

? ? ? ? ? ? ? ? tuple

? ? ? ? ? ? ? ? ((

? ? ? ? ? ? ? ? 11

? ? ? ? ? ? ? ? ,?

? ? ? ? ? ? ? ? 22

? ? ? ? ? ? ? ? ,?

? ? ? ? ? ? ? ? 33

? ? ? ? ? ? ? ? ,?

? ? ? ? ? ? ? ? 44

? ? ? ? ? ? ? ? ,?

? ? ? ? ? ? ? ? 55

? ? ? ? ? ? ? ? ))

? ? ? ? ? ? ? ??

? ? ? ? ? ? ? ?

? ? ? ? ??

? ? ? ? ?

? ? ? ??

? ? ? ?

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

? ? ? ??

? ? ? ??

? ? ? ? 索引切片循環(huán)長度包含創(chuàng)建元組的時候后面加個逗號,用以區(qū)分方法和元素,如:(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ǒng)計指定元素出現(xiàn)的次數(shù) """

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

? ? ? ? """ 獲取指定元素在元組中的下標(biāo) """

? ? ? ? """

? ? ? ? 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、字典(無序)

? ?

??

? ?創(chuàng)建字典:

? ?

? ?

? ??

? ? ?

? ? ??

? ? ? ?

? ? ? ? ??

? ? ? ? ? ?1

? ? ? ? ? ?

? ? ? ? ??

? ? ? ? ? ?2

? ? ? ? ? ?

? ? ? ? ??

? ? ? ? ? ?3

? ? ? ? ? ??

? ? ? ? ? ?

? ? ? ? ? ?

? ? ? ? ? ? person?

? ? ? ? ? ? =?

? ? ? ? ? ? {

? ? ? ? ? ? "name"

? ? ? ? ? ? :?

? ? ? ? ? ? "mr.wu"

? ? ? ? ? ? ,?

? ? ? ? ? ? 'age'

? ? ? ? ? ? :?

? ? ? ? ? ? 18

? ? ? ? ? ? }

? ? ? ? ? ??

? ? ? ? ? ?

? ? ? ? ? ? 或

? ? ? ? ? ??

? ? ? ? ? ?

? ? ? ? ? ? person?

? ? ? ? ? ? =?

? ? ? ? ? ? dict

? ? ? ? ? ? ({

? ? ? ? ? ? "name"

? ? ? ? ? ? :?

? ? ? ? ? ? "mr.wu"

? ? ? ? ? ? ,?

? ? ? ? ? ? 'age'

? ? ? ? ? ? :?

? ? ? ? ? ? 18

? ? ? ? ? ? })

? ? ? ? ? ??

? ? ? ? ? ?

? ? ??

? ? ?

? ??

? ??

? ? 常用操作:?

? ? 索引新增刪除鍵、值、鍵值對循環(huán)長度數(shù)字,字符串,元組,bool(如果是True當(dāng)key,則key轉(zhuǎn)成1,False,key轉(zhuǎn)成0),可以作為字典的key 字典的for循環(huán),默認(rèn)循環(huán)所有的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__

? ? ? ? """ 清除內(nèi)容 """

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

? ? ? ? """

? ? ? ? 根據(jù)序列創(chuàng)建字典,并且指定統(tǒng)一的值(最多只能傳兩個序列)

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

? ? ? ? ? ? ? ? dict.fromkeys(['a','b','c'],['a','b','c']) 創(chuàng)建的字典為:{'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__

? ? ? ? """ 根據(jù)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對應(yīng)的value,如果key不存在,則返回d,d默認(rèn)空,可指定值 """

? ? ? ? """

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

? ? ? ? """ 獲取并在字典中移除(隨機移除一個),默認(rèn)移除后返回的是元祖(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不存在,則創(chuàng)建,如果存在,則返回已存在的值且不修改 """

? ? ? ? """ 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對應(yīng)的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集合,是一個無序且不重復(fù)的元素集合?

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

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

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

? ? 2.沒有重復(fù)的元素?

? ? 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,相當(dāng)于: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,相當(dāng)于: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

? ? ? ? """ 是否是子集:相當(dāng)于:set1 <= set2 """

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

? ? ? ? pass

?

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

? ? ? ? """ 是否是父集集:相當(dāng)于: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循環(huán)

? ? ?

? ??

? ? ?用戶按照順序循環(huán)可迭代對象中的內(nèi)容,

? ? ?

? ??

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

? ? ?

? ??

? ? ?指定范圍,生成指定的數(shù)字

? ? ?

? ? ?

? ? ??

? ? ? ?

? ? ? ??

? ? ? ? ?

? ? ? ? ? ??

? ? ? ? ? ? ?1

? ? ? ? ? ? ?

? ? ? ? ? ??

? ? ? ? ? ? ?2

? ? ? ? ? ? ?

? ? ? ? ? ??

? ? ? ? ? ? ?3

? ? ? ? ? ? ?

? ? ? ? ? ??

? ? ? ? ? ? ?4

? ? ? ? ? ? ?

? ? ? ? ? ??

? ? ? ? ? ? ?5

? ? ? ? ? ? ?

? ? ? ? ? ??

? ? ? ? ? ? ?6

? ? ? ? ? ? ?

? ? ? ? ? ??

? ? ? ? ? ? ?7

? ? ? ? ? ? ?

? ? ? ? ? ??

? ? ? ? ? ? ?8

? ? ? ? ? ? ??

? ? ? ? ? ? ?

? ? ? ? ? ? ?

? ? ? ? ? ? ? print?

? ? ? ? ? ? ? range

? ? ? ? ? ? ? (

? ? ? ? ? ? ? 1

? ? ? ? ? ? ? ,?

? ? ? ? ? ? ? 10

? ? ? ? ? ? ? )

? ? ? ? ? ? ??

? ? ? ? ? ? ?

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

? ? ? ? ? ? ??

? ? ? ? ? ? ?

? ? ? ? ? ? ? ?

? ? ? ? ? ? ??

? ? ? ? ? ? ?

? ? ? ? ? ? ? print?

? ? ? ? ? ? ? range

? ? ? ? ? ? ? (

? ? ? ? ? ? ? 1

? ? ? ? ? ? ? ,?

? ? ? ? ? ? ? 10

? ? ? ? ? ? ? ,?

? ? ? ? ? ? ? 2

? ? ? ? ? ? ? )

? ? ? ? ? ? ??

? ? ? ? ? ? ?

? ? ? ? ? ? ? # 結(jié)果:[1, 3, 5, 7, 9]

? ? ? ? ? ? ??

? ? ? ? ? ? ?

? ? ? ? ? ? ? ?

? ? ? ? ? ? ??

? ? ? ? ? ? ?

? ? ? ? ? ? ? print?

? ? ? ? ? ? ? range

? ? ? ? ? ? ? (

? ? ? ? ? ? ? 30

? ? ? ? ? ? ? ,?

? ? ? ? ? ? ? 0

? ? ? ? ? ? ? ,?

? ? ? ? ? ? ? -

? ? ? ? ? ? ? 2

? ? ? ? ? ? ? )

? ? ? ? ? ? ??

? ? ? ? ? ? ?

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

? ? ? ? ? ? ??

? ? ? ? ? ? ?

? ? ? ??

? ? ? ?

? ? ??

? ? ?

? ??

? ?

?   ?

?

?

轉(zhuǎn)載于:https://www.cnblogs.com/jqbai/articles/8628048.html

總結(jié)

以上是生活随笔為你收集整理的[转载] python之路《第二篇》Python基本数据类型的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 亚洲黄页 | 新x8x8拨牐拨牐永久免费影库 | 超碰在线免费 | 免费在线观看一区二区 | 人人爽爽人人 | 色八戒av| av无码久久久久久不卡网站 | 美女隐私免费网站 | jizzjizz欧美69巨大 | 97成人免费视频 | 亚洲自拍第二页 | 亚洲精品久久久久久国 | 秘密基地在线观看完整版免费 | 国产成人无码精品久久久电影 | 久久视频一区 | www天堂在线| www日韩在线 | 国产精品福利一区二区 | 成人国产精品视频 | 欧美日韩三级在线 | 国产网站在线看 | 国产精品久久久久久久久久久久久久久 | 91精品国产99久久久久久红楼 | 亚洲成人中文 | 国产香蕉视频在线 | 国产青青草视频 | 天天宗合网 | 天堂婷婷| 国产成人在线免费视频 | 又黄又湿的网站 | 岛国裸体写真hd在线 | 国产后入清纯学生妹 | 黑色丝袜吻戏亲胸摸腿 | 国产对白视频 | 久久无码精品丰满人妻 | 日韩精品一区二区三区不卡在线 | 北岛玲在线 | 国产美女无遮挡永久免费观看 | 人人澡人人澡 | 国产情侣激情自拍 | 玖玖热在线视频 | 国产一区二区三区在线免费 | 亚洲欧美另类图片 | 日韩在线视频免费 | 欧美一区二区三区四区五区 | 一级久久久久久久 | 日韩女优在线观看 | xxx综合网| 免费av电影网站 | 国产精品久久久久久免费播放 | 麻豆私人影院 | 香蕉黄视频 | 一区二区三区四区五区在线视频 | 国产精品探花一区二区在线观看 | 黄色片小视频 | a级免费视频 | 午夜国产在线观看 | 日本美女全裸 | 日韩一区二区三区四区五区 | 亚洲一区二区不卡在线观看 | 午夜精品无码一区二区三区 | 国产亚洲性欧美日韩在线观看软件 | yy6080午夜| 内射一区二区 | 欧美综合视频在线观看 | 亚洲高清在线观看 | 毛片成人网 | 亚洲人成人一区二区在线观看 | 成人看片黄a免费看视频 | 国产性猛交╳xxx乱大交一区 | 韩国精品久久久 | 99热偷拍 | 国产又粗又黄又猛 | 欧美女同在线 | 欧美久久久久久久 | 乌克兰性极品xxxhd | 国内精品久久久久 | youjizz在线视频| 台湾佬美性中文娱乐 | xx色综合| 亚洲第一色网 | 天天做天天爱天天爽综合网 | 涩涩成人网 | 第一宅男av导航入口 | 漂亮人妻被黑人久久精品 | www在线观看免费视频 | 法国极品成人h版 | 欧美做受高潮1 | 国产综合精品视频 | 成年人网站在线免费观看 | 激情网页 | 国产精品自拍偷拍视频 | 黄色av影院| 亚洲国产视频一区二区三区 | 久久狠狠高潮亚洲精品 | 精品丰满人妻无套内射 | 国产午夜免费 | 成人无高清96免费 | 亚洲免费观看高清完整版在线 |