服务器之家

服务器之家 > 正文

Python数据类型详解(一)字符串

时间:2020-08-22 09:41     来源/作者:aylin

一.基本数据类型

  整数:int
  字符串:str(注:\t等于一个tab键)
  布尔值: bool
  列表:list
  列表用[]
  元祖:tuple
  元祖用()
  字典:dict

注:所有的数据类型都存在想对应的类列里

二.字符串所有数据类型:

基本操作:

索引,切片,追加,删除,长度,切片,循环,包含

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
class str(object):
  """
  str(object='') -> str
  str(bytes_or_buffer[, encoding[, errors]]) -> str
  
  Create a new string object from the given object. If encoding or
  errors is specified, then the object must expose a data buffer
  that will be decoded using the given encoding and error handler.
  Otherwise, returns the result of object.__str__() (if defined)
  or repr(object).
  encoding defaults to sys.getdefaultencoding().
  errors defaults to 'strict'.
  """
  def capitalize(self): # real signature unknown; restored from __doc__
    """
    S.capitalize() -> str
    
    Return a capitalized version of S, i.e. make the first character
    have upper case and the rest lower case.(返回一个大写版本的年代,即第一个字符,有大写,其余小写。)
    """
    return ""
 
  def casefold(self): # real signature unknown; restored from __doc__
    """
    S.casefold() -> str
    
    Return a version of S suitable for caseless comparisons.(返回一个版本的S适合caseless比较。)
    """
    return ""
 
  def center(self, width, fillchar=None): # real signature unknown; restored from __doc__
    """
    S.center(width[, fillchar]) -> str
    
    Return S centered in a string of length width. Padding is
    done using the specified fill character (default is a space)(返回年代集中在一个字符串的长度宽度。填充使用指定的填充字符(默认是一个空间))
    """
    return ""
 
  def count(self, sub, start=None, end=None): # real signature unknown; restored from __doc__
    """
    S.count(sub[, start[, end]]) -> int
    
    Return the number of non-overlapping occurrences of substring sub in
    string S[start:end]. Optional arguments start and end are
    interpreted as in slice notation.
    (返回的数量重叠出现的子串子字符串(开始:结束)。可选参数的开始和结束解释为片符号。)
    """
    return 0
 
  def encode(self, encoding='utf-8', errors='strict'): # real signature unknown; restored from __doc__
    """
    S.encode(encoding='utf-8', errors='strict') -> bytes
    
    Encode S using the codec registered for encoding. Default encoding
    is 'utf-8'. errors may be given to set a different error
    handling scheme. Default is 'strict' meaning that encoding errors raise
    a UnicodeEncodeError. Other possible values are 'ignore', 'replace' and
    'xmlcharrefreplace' as well as any other name registered with
    codecs.register_error that can handle UnicodeEncodeErrors.
    """
    return b""
 
  def expandtabs(self, tabsize=8): # real signature unknown; restored from __doc__
    """
    S.expandtabs(tabsize=8) -> str
    
    Return a copy of S where all tab characters are expanded using spaces.
    If tabsize is not given, a tab size of 8 characters is assumed.
    (返回一个副本的年代,所有制表符使用空间扩大。如果tabsize不是,一个标签大小8个字符。)
    """
    return ""
 
  def find(self, sub, start=None, end=None): # real signature unknown; restored from __doc__
    """
    S.find(sub[, start[, end]]) -> int
    
    Return the lowest index in S where substring sub is found,
    such that sub is contained within S[start:end]. Optional
    arguments start and end are interpreted as in slice notation.
    Return -1 on failure.
    (回报指数最低的年代找到子字符串的子,这样的子是包含在S[开始:结束]。可选参数中解释为开始和结束符号。)
    """
    return 0
 
  def format(self, *args, **kwargs): # known special case of str.format
    """
    S.format(*args, **kwargs) -> str
    
    Return a formatted version of S, using substitutions from args and kwargs.
    The substitutions are identified by braces ('{' and '}').
    (返回一个格式化的年代,利用参数的替换和kwargs。替换被括号(“{”和“}”)。)
    """
    pass
 
  def format_map(self, mapping): # real signature unknown; restored from __doc__
    """
    S.format_map(mapping) -> str
    
    Return a formatted version of S, using substitutions from mapping.
    The substitutions are identified by braces ('{' and '}').
    (返回一个格式化的年代,利用映射的替换。替换被括号(“{”和“}”)。)
    """
    return ""
 
  def index(self, sub, start=None, end=None): # real signature unknown; restored from __doc__
    """
    S.index(sub[, start[, end]]) -> int
    
    Like S.find() but raise ValueError when the substring is not found.
    (像S.find(),但没有找到子字符串时提高ValueError)
    """
    return 0
 
  def isalnum(self): # real signature unknown; restored from __doc__
    """
    S.isalnum() -> bool
    
    Return True if all characters in S are alphanumeric
    and there is at least one character in S, False otherwise.
    (如果在年代所有的人物都是字母数字返回True和至少有一个角色年代,否则假。)
    """
    return False
 
  def isalpha(self): # real signature unknown; restored from __doc__
    """
    S.isalpha() -> bool
    
    Return True if all characters in S are alphabetic
    and there is at least one character in S, False otherwise.
    (如果在年代所有的人物都是字母返回True和至少有一个角色年代,否则假。)
    """
    return False
 
  def isdigit(self): # real signature unknown; restored from __doc__
    """
    S.isdigit() -> bool
    
    Return True if all characters in S are digits
    and there is at least one character in S, False otherwise.
    (返回True,如果在年代所有的人物都是数字和至少有一个角色年代,否则假。)
    """
    return False
 
  def islower(self): # real signature unknown; restored from __doc__
    """
    S.islower() -> bool
    
    Return True if all cased characters in S are lowercase and there is
    at least one cased character in S, False otherwise.
    (返回True,如果所有S是小写,下套管的字符至少有一个下套管在年代,否则假。)
    """
    return False
 
  def isnumeric(self): # real signature unknown; restored from __doc__
    """
    S.isnumeric() -> bool
    
    Return True if there are only numeric characters in S,
    False otherwise.
    (返回True,如果只有数字字符,否则错误。)
    """
    return False
 
  def isprintable(self): # real signature unknown; restored from __doc__
    """
    S.isprintable() -> bool
    
    Return True if all characters in S are considered
    printable in repr() or S is empty, False otherwise.
    (如果在年代所有的人物都是考虑返回True,可打印在repr()或年代是空的,否则假。)
    """
    return False
 
  def isspace(self): # real signature unknown; restored from __doc__
    """
    S.isspace() -> bool
    
    Return True if all characters in S are whitespace
    and there is at least one character in S, False otherwise.
    (返回True,如果在年代所有的人物都是空白和至少有一个角色年代,否则假。)
    """
    return False
 
  def istitle(self): # real signature unknown; restored from __doc__
    """
    S.istitle() -> bool
    
    Return True if S is a titlecased string and there is at least one
    character in S, i.e. upper- and titlecase characters may only
    follow uncased characters and lowercase characters only cased ones.
    Return False otherwise.
    (返回True,如果S titlecased字符串和至少有一个个性的年代,即上,可能只titlecase字符遵循外露的字符和小写字符只下套管。否则返回假。)
    """
    return False
 
  def isupper(self): # real signature unknown; restored from __doc__
    """
    S.isupper() -> bool
    
    Return True if all cased characters in S are uppercase and there is
    at least one cased character in S, False otherwise.
    (返回True,如果所有S是大写,下套管的字符至少有一个下套管在年代,否则假。)
    """
    return False
 
  def join(self, iterable): # real signature unknown; restored from __doc__
    """
    S.join(iterable) -> str
    
    Return a string which is the concatenation of the strings in the
    iterable. The separator between elements is S.
    (返回一个字符串的连接字符串iterable。元素之间的分隔符是S。)
    """
    return ""
 
  def ljust(self, width, fillchar=None): # real signature unknown; restored from __doc__
    """
    S.ljust(width[, fillchar]) -> str
    
    Return S left-justified in a Unicode string of length width. Padding is
    done using the specified fill character (default is a space).
    (返回年代左对齐的Unicode字符串的长度宽度。填充使用指定的填充字符(默认值是一个空格)。)
    """
    return ""
 
  def lower(self): # real signature unknown; restored from __doc__
    """
    S.lower() -> str
    
    Return a copy of the string S converted to lowercase.
    (返回的字符串转换为小写。)
    """
    return ""
 
  def lstrip(self, chars=None): # real signature unknown; restored from __doc__
    """
    S.lstrip([chars]) -> str
    
    Return a copy of the string S with leading whitespace removed.
    If chars is given and not None, remove characters in chars instead.
    (返回字符串的副本删除前导空白。如果字符而不是没有,删除字符字符代替。)
    """
    return ""
 
  def partition(self, sep): # real signature unknown; restored from __doc__
    """
    S.partition(sep) -> (head, sep, tail)
    
    Search for the separator sep in S, and return the part before it,
    the separator itself, and the part after it. If the separator is not
    found, return S and two empty strings.
    (搜索分离器sep的年代,并返回之前的部分一样,分隔符本身,后一部分。如果分隔符发现,还和两个空字符串。)
    """
    pass
 
  def replace(self, old, new, count=None): # real signature unknown; restored from __doc__
    """
    S.replace(old, new[, count]) -> str
    
    Return a copy of S with all occurrences of substring
    old replaced by new. If the optional argument count is
    given, only the first count occurrences are replaced.
    (返回一个年代出现的所有子字符串的副本老被新的取代。如果可选参数计数,只替换第一计数。)
    """
    return ""
 
  def rfind(self, sub, start=None, end=None): # real signature unknown; restored from __doc__
    """
    S.rfind(sub[, start[, end]]) -> int
    
    Return the highest index in S where substring sub is found,
    such that sub is contained within S[start:end]. Optional
    arguments start and end are interpreted as in slice notation.  
    Return -1 on failure.
    (回报最高的指数在年代找到子字符串的子,这样的子是包含在S[开始:结束]。可选参数中解释为开始和结束符号。)
    """
    return 0
 
  def rindex(self, sub, start=None, end=None): # real signature unknown; restored from __doc__
    """
    S.rindex(sub[, start[, end]]) -> int
    
    Like S.rfind() but raise ValueError when the substring is not found.
    (像S.rfind(),但没有找到子字符串时提高ValueError。)
    """
    return 0
 
  def rjust(self, width, fillchar=None): # real signature unknown; restored from __doc__
    """
    S.rjust(width[, fillchar]) -> str
    
    Return S right-justified in a string of length width. Padding is
    done using the specified fill character (default is a space).
    (返回右对齐的在一个字符串的长度宽度。填充使用指定的填充字符(默认值是一个空格))
    """
    return ""
 
  def rpartition(self, sep): # real signature unknown; restored from __doc__
    """
    S.rpartition(sep) -> (head, sep, tail)
    
    Search for the separator sep in S, starting at the end of S, and return
    the part before it, the separator itself, and the part after it. If the
    separator is not found, return two empty strings and S.
    (寻找分离器在年代,9月开始的年代,并返回之前的部分一样,分离器本身,后一部分。如果没有找到分隔符,返回两个空字符串和年代。)
    """
    pass
 
  def rsplit(self, sep=None, maxsplit=-1): # real signature unknown; restored from __doc__
    """
    S.rsplit(sep=None, maxsplit=-1) -> list of strings
    
    Return a list of the words in S, using sep as the
    delimiter string, starting at the end of the string and
    working to the front. If maxsplit is given, at most maxsplit
    splits are done. If sep is not specified, any whitespace string
    is a separator.
    (返回一个列表的单词,使用9月作为分隔符字符串,字符串的结束和开始工作到前面来。如果maxsplit,最多maxsplit分割完成。如果没有指定9月,任何空白字符串是一个分隔符。)
    """
    return []
 
  def rstrip(self, chars=None): # real signature unknown; restored from __doc__
    """
    S.rstrip([chars]) -> str
    
    Return a copy of the string S with trailing whitespace removed.
    If chars is given and not None, remove characters in chars instead.
    (返回一个字符串的副本年代尾随空格移除。如果字符而不是没有,删除字符字符代替。)
    """
    return ""
 
  def split(self, sep=None, maxsplit=-1): # real signature unknown; restored from __doc__
    """
    S.split(sep=None, maxsplit=-1) -> list of strings
    
    Return a list of the words in S, using sep as the
    delimiter string. If maxsplit is given, at most maxsplit
    splits are done. If sep is not specified or is None, any
    whitespace string is a separator and empty strings are
    removed from the result.
    (返回一个列表的单词,使用9月作为
    分隔符的字符串。如果maxsplit,最多maxsplit
    分割完成。如果没有指定9月或没有,
    空白字符串分隔符和空字符串
    从结果中删除。)
    """
    return []
 
  def splitlines(self, keepends=None): # real signature unknown; restored from __doc__
    """
    S.splitlines([keepends]) -> list of strings
    
    Return a list of the lines in S, breaking at line boundaries.
    Line breaks are not included in the resulting list unless keepends
    is given and true.(返回一个列表的行,行打破界限。换行符不包括在结果列表,除非keepends和真正的。)
    """
    return []
 
  def startswith(self, prefix, start=None, end=None): # real signature unknown; restored from __doc__
    """
    S.startswith(prefix[, start[, end]]) -> bool
    
    Return True if S starts with the specified prefix, False otherwise.
    With optional start, test S beginning at that position.
    With optional end, stop comparing S at that position.
    prefix can also be a tuple of strings to try.
    (返回True,如果年代始于指定的前缀,否则假。
     可选的开始,测试年代开始在那个位置。
     带有可选结束,停止比较年代在那个位置。
     前缀也可以尝试一个元组的字符串。)
    """
    return False
 
  def strip(self, chars=None): # real signature unknown; restored from __doc__
    """
    S.strip([chars]) -> str
    
    Return a copy of the string S with leading and trailing
    whitespace removed.
    If chars is given and not None, remove characters in chars instead.(返回字符串的副本与前导和尾随空格移除。如果字符而不是没有,删除字符字符代替。)
    """
    return ""
 
  def swapcase(self): # real signature unknown; restored from __doc__
    """
    S.swapcase() -> str
    
    Return a copy of S with uppercase characters converted to lowercase
    and vice versa.(返回一个副本的年代大写字符转换为小写反之亦然)
    """
    return ""
 
  def title(self): # real signature unknown; restored from __doc__
    """
    S.title() -> str
    
    Return a titlecased version of S, i.e. words start with title case
    characters, all remaining cased characters have lower case.(返回一个titlecased版本的年代,即单词从标题开始字符,所有剩余的下套管字符小写)
    """
    return ""
 
  def translate(self, table): # real signature unknown; restored from __doc__
    """
    S.translate(table) -> str
    
    Return a copy of the string S in which each character has been mapped
    through the given translation table. The table must implement
    lookup/indexing via __getitem__, for instance a dictionary or list,
    mapping Unicode ordinals to Unicode ordinals, strings, or None. If
    this operation raises LookupError, the character is left untouched.
    Characters mapped to None are deleted.(返回的字符串的每个字符被映射通过给定的转换表。
    表必须实现通过__getitem__查找/索引,例如字典或列表,Unicode依次映射到Unicode序数、字符串或没有。
    如果此操作提出了LookupError,字符保持不变)
    """
    return ""
 
  def upper(self): # real signature unknown; restored from __doc__
    """
    S.upper() -> str
    
    Return a copy of S converted to uppercase.(返回一个副本年代转换为大写)
    """
    return ""
 
  def zfill(self, width): # real signature unknown; restored from __doc__
    """
    S.zfill(width) -> str
    
    Pad a numeric string S with zeros on the left, to fill a field
    of the specified width. The string S is never truncated.(垫一个数字字符串与0年代在左边,填补一个字段指定的宽度。字符串年代不会截断。)
    """
    return ""
 
  def __add__(self, *args, **kwargs): # real signature unknown
    """ Return self+value. """
    pass
 
  def __contains__(self, *args, **kwargs): # real signature unknown
    """ Return key in self. """
    pass
 
  def __eq__(self, *args, **kwargs): # real signature unknown
    """ Return self==value. """
    pass
 
  def __format__(self, format_spec): # real signature unknown; restored from __doc__
    """
    S.__format__(format_spec) -> str
    
    Return a formatted version of S as described by format_spec.
    """
    return ""
 
  def __getattribute__(self, *args, **kwargs): # real signature unknown
    """ Return getattr(self, name). """
    pass
 
  def __getitem__(self, *args, **kwargs): # real signature unknown
    """ Return self[key]. """
    pass
 
  def __getnewargs__(self, *args, **kwargs): # real signature unknown
    pass
 
  def __ge__(self, *args, **kwargs): # real signature unknown
    """ Return self>=value. """
    pass
 
  def __gt__(self, *args, **kwargs): # real signature unknown
    """ Return self>value. """
    pass
 
  def __hash__(self, *args, **kwargs): # real signature unknown
    """ Return hash(self). """
    pass
 
  def __init__(self, value='', encoding=None, errors='strict'): # known special case of str.__init__
    """
    str(object='') -> str
    str(bytes_or_buffer[, encoding[, errors]]) -> str
    
    Create a new string object from the given object. If encoding or
    errors is specified, then the object must expose a data buffer
    that will be decoded using the given encoding and error handler.
    Otherwise, returns the result of object.__str__() (if defined)
    or repr(object).
    encoding defaults to sys.getdefaultencoding().
    errors defaults to 'strict'.
    # (copied from class doc)
    """
    pass
 
  def __iter__(self, *args, **kwargs): # real signature unknown
    """ Implement iter(self). """
    pass
 
  def __len__(self, *args, **kwargs): # real signature unknown
    """ Return len(self). """
    pass
 
  def __le__(self, *args, **kwargs): # real signature unknown
    """ Return self<=value. """
    pass
 
  def __lt__(self, *args, **kwargs): # real signature unknown
    """ Return self<value. """
    pass
 
  def __mod__(self, *args, **kwargs): # real signature unknown
    """ Return self%value. """
    pass
 
  def __mul__(self, *args, **kwargs): # real signature unknown
    """ Return self*value.n """
    pass
 
  @staticmethod # known case of __new__
  def __new__(*args, **kwargs): # real signature unknown
    """ Create and return a new object. See help(type) for accurate signature. """
    pass
 
  def __ne__(self, *args, **kwargs): # real signature unknown
    """ Return self!=value. """
    pass
 
  def __repr__(self, *args, **kwargs): # real signature unknown
    """ Return repr(self). """
    pass
 
  def __rmod__(self, *args, **kwargs): # real signature unknown
    """ Return value%self. """
    pass
 
  def __rmul__(self, *args, **kwargs): # real signature unknown
    """ Return self*value. """
    pass
 
  def __sizeof__(self): # real signature unknown; restored from __doc__
    """ S.__sizeof__() -> size of S in memory, in bytes """
    pass
 
  def __str__(self, *args, **kwargs): # real signature unknown
    """ Return str(self). """
    pass
 
 
class super(object):
  """
  super() -> same as super(__class__, <first argument>)
  super(type) -> unbound super object
  super(type, obj) -> bound super object; requires isinstance(obj, type)
  super(type, type2) -> bound super object; requires issubclass(type2, type)
  Typical use to call a cooperative superclass method:
  class C(B):
    def meth(self, arg):
      super().meth(arg)
  This works for class methods too:
  class C(B):
    @classmethod
    def cmeth(cls, arg):
      super().cmeth(arg)
  """
  def __getattribute__(self, *args, **kwargs): # real signature unknown
    """ Return getattr(self, name). """
    pass
 
  def __get__(self, *args, **kwargs): # real signature unknown
    """ Return an attribute of instance, which is of type owner. """
    pass
 
  def __init__(self, type1=None, type2=None): # known special case of super.__init__
    """
    super() -> same as super(__class__, <first argument>)
    super(type) -> unbound super object
    super(type, obj) -> bound super object; requires isinstance(obj, type)
    super(type, type2) -> bound super object; requires issubclass(type2, type)
    Typical use to call a cooperative superclass method:
    class C(B):
      def meth(self, arg):
        super().meth(arg)
    This works for class methods too:
    class C(B):
      @classmethod
      def cmeth(cls, arg):
        super().cmeth(arg)
    
    # (copied from class doc)
    """
    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 __repr__(self, *args, **kwargs): # real signature unknown
    """ Return repr(self). """
    pass
 
  __self_class__ = property(lambda self: type(object))
  """the type of the instance invoking super(); may be None
 
  :type: type
  """
 
  __self__ = property(lambda self: type(object))
  """the instance invoking super(); may be None
 
  :type: type
  """
 
  __thisclass__ = property(lambda self: type(object))
  """the class invoking super()
 
  :type: type
  """
 
 
 
class SyntaxWarning(Warning):
  """ Base class for warnings about dubious syntax. """
  def __init__(self, *args, **kwargs): # real signature unknown
    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
 
 
class SystemError(Exception):
  """
  Internal error in the Python interpreter.
  
  Please report this to the Python maintainer, along with the traceback,
  the Python version, and the hardware/OS platform and version.
  """
  def __init__(self, *args, **kwargs): # real signature unknown
    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
 
 
class SystemExit(BaseException):
  """ Request to exit from the interpreter. """
  def __init__(self, *args, **kwargs): # real signature unknown
    pass
 
  code = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
  """exception code"""
 
 
 
class TabError(IndentationError):
  """ Improper mixture of spaces and tabs. """
  def __init__(self, *args, **kwargs): # real signature unknown
    pass
 
 
class TimeoutError(OSError):
  """ Timeout expired. """
  def __init__(self, *args, **kwargs): # real signature unknown
    pass
 
 
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
 
 
class type(object):
  """
  type(object_or_name, bases, dict)
  type(object) -> the object's type
  type(name, bases, dict) -> a new type
  """
  def mro(self): # real signature unknown; restored from __doc__
    """
    mro() -> list
    return a type's method resolution order
    """
    return []
 
  def __call__(self, *args, **kwargs): # real signature unknown
    """ Call self as a function. """
    pass
 
  def __delattr__(self, *args, **kwargs): # real signature unknown
    """ Implement delattr(self, name). """
    pass
 
  def __dir__(self): # real signature unknown; restored from __doc__
    """
    __dir__() -> list
    specialized __dir__ implementation for types
    """
    return []
 
  def __getattribute__(self, *args, **kwargs): # real signature unknown
    """ Return getattr(self, name). """
    pass
 
  def __init__(cls, what, bases=None, dict=None): # known special case of type.__init__
    """
    type(object_or_name, bases, dict)
    type(object) -> the object's type
    type(name, bases, dict) -> a new type
    # (copied from class doc)
    """
    pass
 
  def __instancecheck__(self): # real signature unknown; restored from __doc__
    """
    __instancecheck__() -> bool
    check if an object is an instance
    """
    return False
 
  @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 __prepare__(self): # real signature unknown; restored from __doc__
    """
    __prepare__() -> dict
    used to create the namespace for the class statement
    """
    return {}
 
  def __repr__(self, *args, **kwargs): # real signature unknown
    """ Return repr(self). """
    pass
 
  def __setattr__(self, *args, **kwargs): # real signature unknown
    """ Implement setattr(self, name, value). """
    pass
 
  def __sizeof__(self): # real signature unknown; restored from __doc__
    """
    __sizeof__() -> int
    return memory consumption of the type object
    """
    return 0
 
  def __subclasscheck__(self): # real signature unknown; restored from __doc__
    """
    __subclasscheck__() -> bool
    check if a class is a subclass
    """
    return False
 
  def __subclasses__(self): # real signature unknown; restored from __doc__
    """ __subclasses__() -> list of immediate subclasses """
    return []
 
  __abstractmethods__ = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
 
 
  __bases__ = (
    object,
  )
  __base__ = object
  __basicsize__ = 864
  __dictoffset__ = 264
  __dict__ = None # (!) real value is ''
  __flags__ = -2146675712
  __itemsize__ = 40
  __mro__ = (
    None, # (!) forward: type, real value is ''
    object,
  )
  __name__ = 'type'
  __qualname__ = 'type'
  __text_signature__ = None
  __weakrefoffset__ = 368
 
 
class TypeError(Exception):
  """ Inappropriate argument type. """
  def __init__(self, *args, **kwargs): # real signature unknown
    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
 
 
class UnboundLocalError(NameError):
  """ Local name referenced but not bound to a value. """
  def __init__(self, *args, **kwargs): # real signature unknown
    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
 
 
class ValueError(Exception):
  """ Inappropriate argument value (of correct type). """
  def __init__(self, *args, **kwargs): # real signature unknown
    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
 
 
class UnicodeError(ValueError):
  """ Unicode related error. """
  def __init__(self, *args, **kwargs): # real signature unknown
    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
 
 
class UnicodeDecodeError(UnicodeError):
  """ Unicode decoding error. """
  def __init__(self, *args, **kwargs): # real signature unknown
    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 __str__(self, *args, **kwargs): # real signature unknown
    """ Return str(self). """
    pass
 
  encoding = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
  """exception encoding"""
 
  end = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
  """exception end"""
 
  object = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
  """exception object"""
 
  reason = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
  """exception reason"""
 
  start = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
  """exception start"""
 
 
 
class UnicodeEncodeError(UnicodeError):
  """ Unicode encoding error. """
  def __init__(self, *args, **kwargs): # real signature unknown
    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 __str__(self, *args, **kwargs): # real signature unknown
    """ Return str(self). """
    pass
 
  encoding = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
  """exception encoding"""
 
  end = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
  """exception end"""
 
  object = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
  """exception object"""
 
  reason = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
  """exception reason"""
 
  start = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
  """exception start"""
 
 
 
class UnicodeTranslateError(UnicodeError):
  """ Unicode translation error. """
  def __init__(self, *args, **kwargs): # real signature unknown
    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 __str__(self, *args, **kwargs): # real signature unknown
    """ Return str(self). """
    pass
 
  encoding = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
  """exception encoding"""
 
  end = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
  """exception end"""
 
  object = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
  """exception object"""
 
  reason = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
  """exception reason"""
 
  start = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
  """exception start"""
 
 
 
class UnicodeWarning(Warning):
  """
  Base class for warnings about Unicode related problems, mostly
  related to conversion problems.
  """
  def __init__(self, *args, **kwargs): # real signature unknown
    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
 
 
class UserWarning(Warning):
  """ Base class for warnings generated by user code. """
  def __init__(self, *args, **kwargs): # real signature unknown
    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
 
 
class ZeroDivisionError(ArithmeticError):
  """ Second argument to a division or modulo operation was zero. """
  def __init__(self, *args, **kwargs): # real signature unknown
    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
 
 
class zip(object):
  """
  zip(iter1 [,iter2 [...]]) --> zip object
  
  Return a zip object whose .__next__() method returns a tuple where
  the i-th element comes from the i-th iterable argument. The .__next__()
  method continues until the shortest iterable in the argument sequence
  is exhausted and then it raises StopIteration.
  """
  def __getattribute__(self, *args, **kwargs): # real signature unknown
    """ Return getattr(self, name). """
    pass
 
  def __init__(self, iter1, iter2=None, *some): # real signature unknown; restored from __doc__
    pass
 
  def __iter__(self, *args, **kwargs): # real signature unknown
    """ Implement iter(self). """
    pass
 
  @staticmethod # known case of __new__
  def __new__(*args, **kwargs): # real signature unknown
    """ Create and return a new object. See help(type) for accurate signature. """
    pass
 
  def __next__(self, *args, **kwargs): # real signature unknown
    """ Implement next(self). """
    pass
 
  def __reduce__(self, *args, **kwargs): # real signature unknown
    """ Return state information for pickling. """
    pass
 
 
class __loader__(object):
  """
  Meta path import for built-in modules.
  
    All methods are either class or static methods to avoid the need to
    instantiate the class.
  """
  def create_module(self, *args, **kwargs): # real signature unknown
    """ Create a built-in module """
    pass
 
  def exec_module(self, *args, **kwargs): # real signature unknown
    """ Exec a built-in module """
    pass
 
  def find_module(self, *args, **kwargs): # real signature unknown
    """
    Find the built-in module.
    
        If 'path' is ever specified then the search is considered a failure.
    
        This method is deprecated. Use find_spec() instead.
    """
    pass
 
  def find_spec(self, *args, **kwargs): # real signature unknown
    pass
 
  def get_code(self, *args, **kwargs): # real signature unknown
    """ Return None as built-in modules do not have code objects. """
    pass
 
  def get_source(self, *args, **kwargs): # real signature unknown
    """ Return None as built-in modules do not have source code. """
    pass
 
  def is_package(self, *args, **kwargs): # real signature unknown
    """ Return False as built-in modules are never packages. """
    pass
 
  def load_module(self, *args, **kwargs): # real signature unknown
    """
    Load the specified module into sys.modules and return it.
    
      This method is deprecated. Use loader.exec_module instead.
    """
    pass
 
  def module_repr(module): # reliably restored by inspect
    """
    Return repr for the module.
    
        The method is deprecated. The import machinery does the job itself.
    """
    pass
 
  def __init__(self, *args, **kwargs): # real signature unknown
    pass
 
  __weakref__ = property(lambda self: object(), lambda self, v: None, lambda self: None) # default
  """list of weak references to the object (if defined)"""
 
 
  __dict__ = None # (!) real value is ''
 
 
# variables with complex values
 
Ellipsis = None # (!) real value is ''
 
NotImplemented = None # (!) real value is ''
 
__spec__ = None # (!) real value is ''

三.所有字符串数据类型举例

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#变量名字变大写
tmp = "zhangyanlin"
tmp_new = tmp.upper()
print(tmp_new)
 
# 输出所有字符定义的所有类型
tmp.upper()
print(dir(tmp))
#['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'format_map', 'index', 'isalnum', 'isalpha', 'isdecimal', 'isdigit', 'isidentifier', 'islower', 'isnumeric', 'isprintable', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'maketrans', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
 
#把首字母变成大写
u1 = "zhang"
u2 = u1.capitalize()
print(u2)
 
#20定义20个位,不够用_补全。
u1 = "zhang"
u2 = u1.center(20 ,'_')
print(u2)
 
#看zh在前10位出现了几次
u1 = "zhangyanlin is zhgod"
u2 = u1.count('zh',0, 10)
print(u2)
 
#获取字符串中大于等于0的位置,小于2的位置
u1 = "zhang"
print(u1.endswith('h',0,2))
 
#将tab转换成空格
u1 = "zhang\t123"
print(u1.expandtabs(20))
 
#找位数,相同只能找第一个出现的,没有想应得会反馈-1
u1 = "zhang hello"
print(u1.find('h'))
 
#站位符0和1是代表站位符
u1 = "name {0}, age {1}"
print(u1.format("zhang",18))
 
u1 = " zhang is yan "
 
#判断是否是字母
print(u1.isalpha())
 
#判断是否是数字
print(u1.isdigit())
 
#判断是否是字母和数字
print(u1.isalnum())
 
#判断是否是小写
print(u1.islower())
 
#判断是否是空格
print(u1.isspace())
 
#判断是不是标题
print(u1.istitle())
 
#判断是不是全部都是大写
print(u1.isupper())
 
#把列表里的内容连接一起
print("_".join(u1))
 
#内容左对齐,右侧填充
print(u1.ljust(1))
 
#内容变小写
print(u1.lower())
 
#移除左边的空格
print(u1.lstrip())
 
#移除右边的空格
print(u1.rstrip())
 
#把有空格的内容分割,变成元祖类型,从左找;rpartition从右开始分割
print(u1.partition('is'))
 
#替换,后面可以加替换几个,从左往右
print(u1.replace('zh','ZH'))
 
#找到一个字符分割,从右,split从左分割
print(u1.rsplit('a',1))
 
#是否以某个字符串开始开始
print(u1.startswith('z'))
 
#移除两边空格(strip)
print(u1.strip())
 
#大写变小写,小写变大写
print(u1.swapcase())
 
#变大写(upper)
print(u1.upper())

四.索引

?
1
2
3
4
5
6
7
u1 = "zhangyanlin"
print(u1[0])
print(u1[1])
print(u1[2])
print(u1[3])
print(u1[4])
print(u1[5]) 

五.切片

?
1
2
3
4
#切出zhan,注:0是代表第一位,4代表小于四,知道第三个数
u1 = "zhangyanlin"
print(u1[0:4])

六.循环切片

1.while使用

?
1
2
3
4
5
u1 = "zhangyanlin"
u2 = 0
while u2 < len(u1):
  print(u1[u2])
  u2+=1

2.for使用

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#循环切片
u1 = "zhangyanlin"
for u2 in u1:
  print(u2)
 
#循环切片,输出除了y
u1 ="zhangyanlin"
for u2 in u1:
  if u2 =="y":
    continue
  print(u2)
 
#循环切片,输出到y后不执行
u1 ="zhangyanlin"
for u2 in u1:
  if u2 =="y":
    break
  print(u2)

相关文章

热门资讯

2020微信伤感网名听哭了 让对方看到心疼的伤感网名大全
2020微信伤感网名听哭了 让对方看到心疼的伤感网名大全 2019-12-26
歪歪漫画vip账号共享2020_yy漫画免费账号密码共享
歪歪漫画vip账号共享2020_yy漫画免费账号密码共享 2020-04-07
Intellij idea2020永久破解,亲测可用!!!
Intellij idea2020永久破解,亲测可用!!! 2020-07-29
最新idea2020注册码永久激活(激活到2100年)
最新idea2020注册码永久激活(激活到2100年) 2020-07-29
男生常说24816是什么意思?女生说13579是什么意思?
男生常说24816是什么意思?女生说13579是什么意思? 2019-09-17
返回顶部