1 classstr(object):2 """
3 str(object='') -> str4 str(bytes_or_buffer[, encoding[, errors]]) -> str5
6 Create a new string object from the given object. If encoding or7 errors is specified, then the object must expose a data buffer8 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
15 def capitalize(self): #real signature unknown; restored from __doc__
16 """
17 S.capitalize() -> str18
19 Return a capitalized version of S, i.e. make the first character20 have upper case and the rest lower case.21 """
22 return
23 #首字母大写
24 #>>> a = "abel"
25 #>>> b = a.capitalize()
26 #>>> b
27 #'Abel'
28
29 def casefold(self): #real signature unknown; restored from __doc__
30 """
31 S.casefold() -> str32
33 Return a version of S suitable for caseless comparisons.34 """
35 return ""
36 #首字母大写变小写
37 #>>> a = "Abel"
38 #>>> b = a.casefold()
39 #>>> b
40 #'abel'
41
42 def center(self, width, fillchar=None): #real signature unknown; restored from __doc__
43 """
44 S.center(width[, fillchar]) -> str45
46 Return S centered in a string of length width. Padding is47 done using the specified fill character (default is a space)48 """
49 return ""
50 #内容居中,width: 总长度; fillchar:空白处填充内容,默认无
51 #>>> a
52 #'Abel'
53 #>>> b = a.center(20, '#')
54 #>>> b
55 #'########Abel########'
56
57 def count(self, sub, start=None, end=None): #real signature unknown; restored from __doc__
58 """
59 S.count(sub[, start[, end]]) -> int60
61 Return the number of non-overlapping occurrences of substring sub in62 string S[start:end]. Optional arguments start and end are63 interpreted as in slice notation.64 """
65 return066 #子序列个数
67 #>>> a = "Abelisgood"
68 #>>> b = a.count('o')
69 #>>> b
70 #2
71 #>>> b = a.count('o', 0, 8)
72 #>>> b
73 #1
74 def encode(self, encoding='utf-8', errors='strict'): #real signature unknown; restored from __doc__
75 """
76 S.encode(encoding='utf-8', errors='strict') -> bytes77
78 Encode S using the codec registered for encoding. Default encoding79 is 'utf-8'. errors may be given to set a different error80 handling scheme. Default is 'strict' meaning that encoding errors raise81 a UnicodeEncodeError. Other possible values are 'ignore', 'replace' and82 'xmlcharrefreplace' as well as any other name registered with83 codecs.register_error that can handle UnicodeEncodeErrors.84 """
85 return b""
86 #编码,针对unicode
87
88 def endswith(self, suffix, start=None, end=None): #real signature unknown; restored from __doc__
89 """
90 S.endswith(suffix[, start[, end]]) -> bool91
92 Return True if S ends with the specified suffix, False otherwise.93 With optional start, test S beginning at that position.94 With optional end, stop comparing S at that position.95 suffix can also be a tuple of strings to try.96 """
97 returnFalse98 #判断str是否以xxx 结束
99 #>>> a
100 #'Abelisgood'
101 #>>> b = a.endswith('d')
102 #>>> b
103 #True
104 #>>> b = a.endswith('g', 0, 7)
105 #>>> b
106 #True
107 def expandtabs(self, tabsize=8): #real signature unknown; restored from __doc__
108 """
109 S.expandtabs(tabsize=8) -> str110
111 Return a copy of S where all tab characters are expanded using spaces.112 If tabsize is not given, a tab size of 8 characters is assumed.113 """
114 return ""
115 #将tab转换成空格,默认一个tab转换成8个空格
116 #>>> a = "a\tbel"
117 #>>> b= a.expandtabs()
118 #>>> b
119 #'a bel'(8个空格)
120 def find(self, sub, start=None, end=None): #real signature unknown; restored from __doc__
121 """
122 S.find(sub[, start[, end]]) -> int123
124 Return the lowest index in S where substring sub is found,125 such that sub is contained within S[start:end]. Optional126 arguments start and end are interpreted as in slice notation.127
128 Return -1 on failure.129 """
130 return0131 #寻找子序列位置,如果没有找到,返回-1
132 #index没有找到,直接报错
133 #>>> a = "asdfjsdakfwejfi"
134 #>>> b = a.find('f', 0, 11)
135 #>>> b
136 #3
137 #>>> b = a.find('z')
138 #>>> b
139 #-1
140 def format(self, *args, **kwargs): #known special case of str.format
141 """
142 S.format(*args, **kwargs) -> str143
144 Return a formatted version of S, using substitutions from args and kwargs.145 The substitutions are identified by braces ('{' and '}').146 """
147 pass
148 #字符串格式化,动态参数。可以拼接字符串。
149 #>>> a = "abel {0} good {1}"
150 #>>> b = a.format('is', 'man')
151 #>>> b
152 #'abel is good man'
153 #>>>
154 def format_map(self, mapping): #real signature unknown; restored from __doc__
155 """
156 S.format_map(mapping) -> str157
158 Return a formatted version of S, using substitutions from mapping.159 The substitutions are identified by braces ('{' and '}').160 """
161 return ""
162
163 def index(self, sub, start=None, end=None): #real signature unknown; restored from __doc__
164 """
165 S.index(sub[, start[, end]]) -> int166
167 Like S.find() but raise ValueError when the substring is not found.168 """
169 return0170 #返回索引位置;可先参数,start:起始位置,end:结束位置,返回一个整数类型(当字符串没有找到时,会提示报错信息)
171 #>>> a = "asdfjsdakfwejfi"
172 #>>> b = a.index('z')
173 #Traceback (most recent call last):
174 #File "", line 1, in
175 #b = a.index('z')
176 #ValueError: substring not found
177 def isalnum(self): #real signature unknown; restored from __doc__
178 """
179 S.isalnum() -> bool180
181 Return True if all characters in S are alphanumeric182 and there is at least one character in S, False otherwise.183 """
184 returnFalse185 #字符串都是字符,数字 或是字符数字组合则为True否则为False
186 #>>> a
187 #'asdfjsdakfwejfi'
188 #>>> b = a.isalnum()
189 #>>> b
190 #True
191
192 #>>> a = ' '
193 #>>> b = a.isalnum()
194 #>>> b
195 #False
196 def isalpha(self): #real signature unknown; restored from __doc__
197 """
198 S.isalpha() -> bool199
200 Return True if all characters in S are alphabetic201 and there is at least one character in S, False otherwise.202 """
203 returnFalse204 #字符串中有一个为字母或所有都是字母都 True 否则为False
205 #>>> a
206 #'abel20'
207 #>>> b = a.isalpha()
208 #>>> b
209 #False
210
211 def isdecimal(self): #real signature unknown; restored from __doc__
212 """
213 S.isdecimal() -> bool214
215 Return True if there are only decimal characters in S,216 False otherwise.217 """
218 returnFalse219 #如果只有十进制则返回True,否则返回False
220 #>>> a = 'abel20'
221 #>>> b = a.isdecimal()
222 #>>> b
223 #False
224
225 def isdigit(self): #real signature unknown; restored from __doc__
226 """
227 S.isdigit() -> bool228
229 Return True if all characters in S are digits230 and there is at least one character in S, False otherwise.231 """
232 returnFalse233 #元素全部为数字时返回 True否则返回 False
234 #>>> a
235 #'abel20'
236 #>>> b = a.isdigit()
237 #>>> b
238 #False
239
240 def isidentifier(self): #real signature unknown; restored from __doc__
241 """
242 S.isidentifier() -> bool243
244 Return True if S is a valid identifier according245 to the language definition.246
247 Use keyword.iskeyword() to test for reserved identifiers248 such as "def" and "class".249 """
250 returnFalse251 #判断字符串是否是合法的标识符(标识符必须合法)返回bool类型
252 #>>> a = '5'
253 #>>> b = a.isidentifier()
254 #>>> b
255 #False
256 #>>> a = 'abel342'
257 #>>> b = a.isidentifier()
258 #>>> b
259 #True
260 def islower(self): #real signature unknown; restored from __doc__
261 """
262 S.islower() -> bool263
264 Return True if all cased characters in S are lowercase and there is265 at least one cased character in S, False otherwise.266 """
267 returnFalse268 #判断字符串中字母是否都是小写,返回bool类型
269 #>>> a
270 #'abel342'
271 #>>> b = a.islower()
272 #>>> b
273 #True
274
275 #>>> a = 'Abel83'
276 #>>> b = a.islower()
277 #>>> b
278 #False
279
280 def isnumeric(self): #real signature unknown; restored from __doc__
281 """
282 S.isnumeric() -> bool283
284 Return True if there are only numeric characters in S,285 False otherwise.286 """
287 returnFalse288 #判断字符串中是否都是数字,返回bool类型
289 #>>> a = 'abel349'
290 #>>> b = a.isnumeric()
291 #>>> b
292 #False
293 #>>> a = '123'
294 #>>> b = a.isnumeric()
295 #>>> b
296 #True
297 def isprintable(self): #real signature unknown; restored from __doc__
298 """
299 S.isprintable() -> bool300
301 Return True if all characters in S are considered302 printable in repr() or S is empty, False otherwise.303 """
304 returnFalse305 #判断是不是只包含可打印字符,返回Bool值
306 #>>> a
307 #'天天向上\t2016'
308 #>>> b = a.isprintable()
309 #>>> b
310 #False
311 #>>> q = 'this is test'
312 #>>> b = a.isprintable()
313 #>>> b
314 #False
315
316 def isspace(self): #real signature unknown; restored from __doc__
317 """
318 S.isspace() -> bool319
320 Return True if all characters in S are whitespace321 and there is at least one character in S, False otherwise.322 """
323 returnFalse324 #判断是不是只包含空格字符,返回bool值
325
326 def istitle(self): #real signature unknown; restored from __doc__
327 """
328 S.istitle() -> bool329
330 Return True if S is a titlecased string and there is at least one331 character in S, i.e. upper- and titlecase characters may only332 follow uncased characters and lowercase characters only cased ones.333 Return False otherwise.334 """
335 returnFalse336 #判断是不是每个词的首字母是不是大写,返回Bool值。一般标题会使用
337
338 def isupper(self): #real signature unknown; restored from __doc__
339 """
340 S.isupper() -> bool341
342 Return True if all cased characters in S are uppercase and there is343 at least one cased character in S, False otherwise.344 """
345 returnFalse346 #判断字符串是不是都是大写,返回bool值
347
348 def join(self, iterable): #real signature unknown; restored from __doc__
349 """
350 S.join(iterable) -> str351
352 Return a string which is the concatenation of the strings in the353 iterable. The separator between elements is S.354 """
355 return ""
356 #返回通过指定字符分隔的新字符串
357 #>>> a = ['a', 'b', 'c', 'f']
358 #>>> b = "_".join(a)
359 #>>> b
360 #'a_b_c_f'
361
362 def ljust(self, width, fillchar=None): #real signature unknown; restored from __doc__
363 """
364 S.ljust(width[, fillchar]) -> str365
366 Return S left-justified in a Unicode string of length width. Padding is367 done using the specified fill character (default is a space).368 """
369 return ""
370 #左对齐,右添充,参数width 宽度(fillchar 添充字符,默认是空格)
371
372 def lower(self): #real signature unknown; restored from __doc__
373 """
374 S.lower() -> str375
376 Return a copy of the string S converted to lowercase.377 """
378 return ""
379 #转换为小写
380
381 def lstrip(self, chars=None): #real signature unknown; restored from __doc__
382 """
383 S.lstrip([chars]) -> str384
385 Return a copy of the string S with leading whitespace removed.386 If chars is given and not None, remove characters in chars instead.387 """
388 return ""
389 #删除左边的空白或自定义的字符
390 #>>> a = " Hi, I'm Abel"
391 #>>> b = a.lstrip()
392 #>>> b
393 #"Hi, I'm Abel"
394 def maketrans(self, *args, **kwargs): #real signature unknown
395 """
396 Return a translation table usable for str.translate().397
398 If there is only one argument, it must be a dictionary mapping Unicode399 ordinals (integers) or characters to Unicode ordinals, strings or None.400 Character keys will be then converted to ordinals.401 If there are two arguments, they must be strings of equal length, and402 in the resulting dictionary, each character in x will be mapped to the403 character at the same position in y. If there is a third argument, it404 must be a string, whose characters will be mapped to None in the result.405 """
406 pass
407 #str.translate()函数配合使用,替换相应的字符
408
409 def partition(self, sep): #real signature unknown; restored from __doc__
410 """
411 S.partition(sep) -> (head, sep, tail)412
413 Search for the separator sep in S, and return the part before it,414 the separator itself, and the part after it. If the separator is not415 found, return S and two empty strings.416 """
417 pass
418 #用于拆分字符串,返回一个包含三个元素的元组;返回一个包含三个元素的元组。如果指定的字符串sep不存在,则返回自己加两个空元素。
419 #>>> a = "Hi, I'm abel"
420 #>>> b = a.partition('a')
421 #>>> b
422 #("Hi, I'm ", 'a', 'bel')
423 #>>> c = a.partition('z')
424 #>>> c
425 #("Hi, I'm abel", '', '')
426 def replace(self, old, new, count=None): #real signature unknown; restored from __doc__
427 """
428 S.replace(old, new[, count]) -> str429
430 Return a copy of S with all occurrences of substring431 old replaced by new. If the optional argument count is432 given, only the first count occurrences are replaced.433 """
434 return ""
435 #使用新的字符串替换老的字符串(可选参数count 指定替换的次数,默认是全部)
436 #>>> a = "Abelisgood"
437 #>>> b = a.replace('o', 'z')
438 #>>> b
439 #'Abelisgzzd'
440 #>>> b = a.replace('o', 'z', 1)
441 #>>> b
442 #'Abelisgzod'
443
444 def rfind(self, sub, start=None, end=None): #real signature unknown; restored from __doc__
445 """
446 S.rfind(sub[, start[, end]]) -> int447
448 Return the highest index in S where substring sub is found,449 such that sub is contained within S[start:end]. Optional450 arguments start and end are interpreted as in slice notation.451
452 Return -1 on failure.453 """
454 return0455 #反向查找,与find 是相反方向
456
457 def rindex(self, sub, start=None, end=None): #real signature unknown; restored from __doc__
458 """
459 S.rindex(sub[, start[, end]]) -> int460
461 Like S.rfind() but raise ValueError when the substring is not found.462 """
463 return0464 #返回字符串所在的索引,与index 相反方向
465
466 def rjust(self, width, fillchar=None): #real signature unknown; restored from __doc__
467 """
468 S.rjust(width[, fillchar]) -> str469
470 Return S right-justified in a string of length width. Padding is471 done using the specified fill character (default is a space).472 """
473 return ""
474 #右对齐,右填充。与ljust 相反
475
476 def rpartition(self, sep): #real signature unknown; restored from __doc__
477 """
478 S.rpartition(sep) -> (head, sep, tail)479
480 Search for the separator sep in S, starting at the end of S, and return481 the part before it, the separator itself, and the part after it. If the482 separator is not found, return two empty strings and S.483 """
484 pass
485 #拆分:与 partition相反,只不过是从字符串的右边开始拆分。
486 def rsplit(self, sep=None, maxsplit=-1): #real signature unknown; restored from __doc__
487 """
488 S.rsplit(sep=None, maxsplit=-1) -> list of strings489
490 Return a list of the words in S, using sep as the491 delimiter string, starting at the end of the string and492 working to the front. If maxsplit is given, at most maxsplit493 splits are done. If sep is not specified, any whitespace string494 is a separator.495 """
496 return[]497 #与split类似,从右边开始拆分,返回一个列表类型,(可选参数maxsplit 每次+- 1 sep 的值默认是空格)
498 def rstrip(self, chars=None): #real signature unknown; restored from __doc__
499 """
500 S.rstrip([chars]) -> str501
502 Return a copy of the string S with trailing whitespace removed.503 If chars is given and not None, remove characters in chars instead.504 """
505 return ""
506 #
507
508 def split(self, sep=None, maxsplit=-1): #real signature unknown; restored from __doc__
509 """
510 S.split(sep=None, maxsplit=-1) -> list of strings511
512 Return a list of the words in S, using sep as the513 delimiter string. If maxsplit is given, at most maxsplit514 splits are done. If sep is not specified or is None, any515 whitespace string is a separator and empty strings are516 removed from the result.517 """
518 return[]519 #从左边开始拆分,返回一个列表类型,(可选参数maxsplit 每次+- 1 sep 的值默认是空格)
520
521 def splitlines(self, keepends=None): #real signature unknown; restored from __doc__
522 """
523 S.splitlines([keepends]) -> list of strings524
525 Return a list of the lines in S, breaking at line boundaries.526 Line breaks are not included in the resulting list unless keepends527 is given and true.528 """
529 return[]530 #拆分多行字符串,以每行一个元素生成一个新的列表,如果是单行字符串,则返回原字符串
531
532 def startswith(self, prefix, start=None, end=None): #real signature unknown; restored from __doc__
533 """
534 S.startswith(prefix[, start[, end]]) -> bool535
536 Return True if S starts with the specified prefix, False otherwise.537 With optional start, test S beginning at that position.538 With optional end, stop comparing S at that position.539 prefix can also be a tuple of strings to try.540 """
541 returnFalse542 #是否以字符串开始(可选参数,start与end 分别代表起始和结束),返回bool值
543
544 def strip(self, chars=None): #real signature unknown; restored from __doc__
545 """
546 S.strip([chars]) -> str547
548 Return a copy of the string S with leading and trailing549 whitespace removed.550 If chars is given and not None, remove characters in chars instead.551 """
552 return ""
553 #去除左边空白或自定义字符串
554
555 def swapcase(self): #real signature unknown; restored from __doc__
556 """
557 S.swapcase() -> str558
559 Return a copy of S with uppercase characters converted to lowercase560 and vice versa.561 """
562 return ""
563 #把字符串的大小写字母互换输出
564
565 def title(self): #real signature unknown; restored from __doc__
566 """
567 S.title() -> str568
569 Return a titlecased version of S, i.e. words start with title case570 characters, all remaining cased characters have lower case.571 """
572 return ""
573 #字符串首字母大写,其他全部小写
574
575 def translate(self, table): #real signature unknown; restored from __doc__
576 """
577 S.translate(table) -> str578
579 Return a copy of the string S in which each character has been mapped580 through the given translation table. The table must implement581 lookup/indexing via __getitem__, for instance a dictionary or list,582 mapping Unicode ordinals to Unicode ordinals, strings, or None. If583 this operation raises LookupError, the character is left untouched.584 Characters mapped to None are deleted.585 """
586 return ""
587 #str.maketrans()函数配合使用,替换相应的字符
588
589 def upper(self): #real signature unknown; restored from __doc__
590 """
591 S.upper() -> str592
593 Return a copy of S converted to uppercase.594 """
595 return ""
596 #与lower 相反,全部转换为大写
597
598 def zfill(self, width): #real signature unknown; restored from __doc__
599 """
600 S.zfill(width) -> str601
602 Pad a numeric string S with zeros on the left, to fill a field603 of the specified width. The string S is never truncated.604 """
605 return ""
606 #回一个添充的字符串,width 添写长度,如果长宽和字符串相等,则直接返回字符串本身,如果长度大小字符串,则用0添充至指定的长度
607
608 def __add__(self, *args, **kwargs): #real signature unknown
609 """Return self+value."""
610 pass
611
612 def __contains__(self, *args, **kwargs): #real signature unknown
613 """Return key in self."""
614 pass
615
616 #str中包含的key或者字节
617
618 def __eq__(self, *args, **kwargs): #real signature unknown
619 """Return self==value."""
620 pass
621
622 def __format__(self, format_spec): #real signature unknown; restored from __doc__
623 """
624 S.__format__(format_spec) -> str625
626 Return a formatted version of S as described by format_spec.627 """
628 return ""
629
630 def __getattribute__(self, *args, **kwargs): #real signature unknown
631 """Return getattr(self, name)."""
632 pass
633
634 #反射时候使用
635
636 def __getitem__(self, *args, **kwargs): #real signature unknown
637 """Return self[key]."""
638 pass
639 #640
641 def __getnewargs__(self, *args, **kwargs): #real signature unknown
642 pass
643
644 def __ge__(self, *args, **kwargs): #real signature unknown
645 """Return self>=value."""
646 pass
647
648 def __gt__(self, *args, **kwargs): #real signature unknown
649 """Return self>value."""
650 pass
651
652 def __hash__(self, *args, **kwargs): #real signature unknown
653 """Return hash(self)."""
654 pass
655
656 def __init__(self, value='', encoding=None, errors='strict'): #known special case of str.__init__
657 """
658 str(object='') -> str659 str(bytes_or_buffer[, encoding[, errors]]) -> str660
661 Create a new string object from the given object. If encoding or662 errors is specified, then the object must expose a data buffer663 that will be decoded using the given encoding and error handler.664 Otherwise, returns the result of object.__str__() (if defined)665 or repr(object).666 encoding defaults to sys.getdefaultencoding().667 errors defaults to 'strict'.668 # (copied from class doc)669 """
670 pass
671
672 def __iter__(self, *args, **kwargs): #real signature unknown
673 """Implement iter(self)."""
674 pass
675
676 def __len__(self, *args, **kwargs): #real signature unknown
677 """Return len(self)."""
678 pass
679
680 def __le__(self, *args, **kwargs): #real signature unknown
681 """Return self<=value."""
682 pass
683
684 def __lt__(self, *args, **kwargs): #real signature unknown
685 """Return self
686 pass
687
688 def __mod__(self, *args, **kwargs): #real signature unknown
689 """Return self%value."""
690 pass
691
692 def __mul__(self, *args, **kwargs): #real signature unknown
693 """Return self*value.n"""
694 pass
695
696 @staticmethod #known case of __new__
697 def __new__(*args, **kwargs): #real signature unknown
698 """Create and return a new object. See help(type) for accurate signature."""
699 pass
700
701 def __ne__(self, *args, **kwargs): #real signature unknown
702 """Return self!=value."""
703 pass
704
705 def __repr__(self, *args, **kwargs): #real signature unknown
706 """Return repr(self)."""
707 pass
708
709 def __rmod__(self, *args, **kwargs): #real signature unknown
710 """Return value%self."""
711 pass
712
713 def __rmul__(self, *args, **kwargs): #real signature unknown
714 """Return self*value."""
715 pass
716
717 def __sizeof__(self): #real signature unknown; restored from __doc__
718 """S.__sizeof__() -> size of S in memory, in bytes"""
719 pass
720
721 def __str__(self, *args, **kwargs): #real signature unknown
722 """Return str(self)."""
723 pass