[转载] 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:
item
2、enumrate
为可迭代的对象添加序号
1
2
3
li
=
[
11
,
22
,
33
]
for
k,v
in
enumerate
(li,
1
):
(k,v)
3、range
指定范围,生成指定的数字
1
2
3
4
5
6
7
8
range
(
1
,
10
)
# 结果:[1, 2, 3, 4, 5, 6, 7, 8, 9]
range
(
1
,
10
,
2
)
# 结果:[1, 3, 5, 7, 9]
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
[转载] python之路《第二篇》Python基本数据类型相关推荐
- Python之路(第二篇):Python基本数据类型字符串(一)
一.基础 1.编码 UTF-8:中文占3个字节 GBK:中文占2个字节 Unicode.UTF-8.GBK三者关系 ascii码是只能表示英文字符,用8个字节表示英文,unicode是统一码,世界通用 ...
- Python之路(第九篇)Python文件操作
一.文件的操作 文件句柄 = open('文件路径+文件名', '模式') 例子 f = open("test.txt","r",encoding = &quo ...
- 网络工程师的python之路pdf_网络工程师的Python之路---Ansible篇
版权声明:我已加入"维权骑士"(http://rightknights.com)的版权保护计划,所有知乎专栏"网路行者"下的文章均为我本人(知乎ID:弈心)原创 ...
- [转帖]虚拟内存探究 -- 第二篇:Python 字节
虚拟内存探究 -- 第二篇:Python 字节 http://blog.coderhuo.tech/2017/10/15/Virtual_Memory_python_bytes/是真看不懂哦 翻译 ...
- Python开发【第二篇】:初识Python
Python开发[第二篇]:初识Python Python简介 Python前世今生 python的创始人为吉多·范罗苏姆(Guido van Rossum).1989年的圣诞节期间,吉多·范罗苏姆为 ...
- 黎想深度访谈腾讯顶级产品经理的进阶之路——第二篇《定位》
16个月精心打磨,9位顶级产品专家研讨提炼,凝聚腾讯产品经验的八集八分钟产品课分别从用户.定位.需求.时机.匠心.危机.合作.商业角度出发,还原产品背后的故事,分享给你腾讯产品的心法.艺形艺意工作室创 ...
- 初学Python——文件操作第二篇
前言:为什么需要第二篇文件操作?因为第一篇的知识根本不足以支撑基本的需求.下面来一一分析. 一.Python文件操作的特点 首先来类比一下,作为高级编程语言的始祖,C语言如何对文件进行操作? 字符(串 ...
- 九、给小白看的第二篇Python基础教程
本文是第二篇 @Author:Runsen @Date:Writern By 2019/04/15 and supplied By 2020/3/31 @公众号:Python之王 本系列Python基 ...
- Python学习【第二篇】 : Python入门
Python安装 Hello World 字符编码 变量 用户输入 模块初识 .pyc是个什么? 数据类型 数据运算 表达式if ...else语句 表达式for 循环 break and conti ...
- 第二篇python安装(1)
python初学基础篇 1 嗨喽!各位观看我文章的大佬们,我是你们没事就喜欢折腾自己来玩的小可爱~~ 我又回来继续更新啦,虽然出了点小问题导致我周六周日没有更新,但是我坚挺的又出现在你们的面前,好啦, ...
最新文章
- cf两边黑屏怎么解决win10_Win10电脑开机黑屏只有鼠标指针无法进入桌面的解决方法...
- java如何对图片去除图片的白色的背景
- 阿里云maven镜像地址
- 毕业2年从月薪400到6000 继续网络梦
- 开发日记-20190820 关键词 读书笔记《Unix环境高级编程(第二版)》DAY 1
- 安装了虚拟机后mysql用不了_在虚拟机上安装mysql,安装好了并且初始化之后,一直无法启动mysql如何解决?...
- 机器学习笔记七之机器学习诊断
- 就这几个简单页面APP,这混小子要我10W块?!大家评评理!
- 万万没想到,EfficientNet居然这么火!
- 【推荐视频】分布式机器学习框架如何助力高维实时推荐系统
- linux+cd英文全称,Linux命令英文全称
- Linux之lastb命令
- 使用js实现画笔功能
- eclipse 连接mysql 数据库 实现数据库基本操作
- Activity标签设置
- CPU当中的分支预测
- 老男孩python第六期
- send函数和recv函数
- 【Django】二手交易市场开发备忘录
- 离线安装docker-compose
热门文章
- hdu4751Divide Groups(dfs枚举完全图集合或者bfs染色)
- java list翻转_JAVA实现两种方法反转单列表
- 汇博工业机器人码垛机怎么写_全自动码垛机器人在企业生产中的地位越来越重要...
- xargs 命令教程
- .net 开发 html框架,Asp.net的开发框架
- matlab bad apple,【bad apple】matlab制作矩阵苹果~
- 安卓system镜像分区_玩机爱好者想要的PT分区到底是什么?可以使现有的安卓系统更快!...
- cuda linux编译器_linux下如何编译CUDA+QT(qtcreator下)
- 路由器mysql密码重置密码_【验证】mysql root密码恢复
- 蓝桥杯练习系统,入门训练,Java版