. 1 # #def_ isspace becomes determines whether all spaces 2 # Test = "asldkf akdjfl; KsdA" . 3 # V = test.isspace () . 4 # Print (V) . 5 . 6 # "istitle first letter of the word is determined whether the size of the write. . 7 # Test = "Finished Process Exit with code 0" . 8 # V = test.istitle () . 9 # Print (V) 10 # title to the first letter of the word, all converted to uppercase. . 11 # Test = " Finished with code 0 Exit Process " 12 is # V = test.title () 13 is # Print (V) 14 15 # The Join ****** 16 # string in each element, as specified by stitching delimiter. 17 # the Test = "You are the wind I am the sand" 18 # Print (the Test) 19 # t = "58 /" 20 # v = t.join (the Test) 21 # # t = "* /" plus v = t.join (test), this formula can be replaced, v = "* /". join (test) result is the same. 22 # Print (v) 23 24- # you * / a * / * wind / children * / I * / are * / sand 25 26 # ljutst () represents the right of the string plus 27 # the Test = "dutianmu" 28 # V = test.ljust (20 is, "2" The output is: dutianmu222222222222 32 33 is # in front of the string of characters together. "R" representative of the left side 34 is # Test = "ksdfeinh" 35 # V = test.rjust (20 is, "*") 36 # Print (V) 37 [ # output: ************ ksdfeinh 38 is 39 # 20 represents the total length. 40 # * fill empty space, a character, an option 41 is # Test = "dkeina" 42 is # V = test.center (20 is, "the") 43 is # Print (V) 44 is # Output Results: Medium Medium Medium medium medium medium medium medium medium dkeina in the middle of the 45 46 is # zfill () default fill "0", generally less than 47 #= Test "laddek" 48 # V = test.zfill (20 is) 49 # Print (V) 50 # # output: 00000000000000laddek 51 is 52 is # islower determines whether all lowercase, lower is lowercase. 53 is # Test = "Alex" 54 is # V1 = test.islower () 55 # V2 = test.lower () 56 is # Print (V1, V2) 57 is # output: False Alex 58 59 # isupper determines whether all caps; the upper is capitalized characters all 60 # Test = "Alex" 61 is # V1 = test.isupper () 62 is # V2 = test.upper () 63 is # Print (V1, V2) 64 # outputs: False ALEX 65 66 # Test = "Alex" 67 # V = test.lstrip () # remove the left margin alex, including the null character \ t or \ n newline 68 # V = test.rstrip () # remove the right margin Alex 69 # V = test.strip () blank # removed about 70 71 is # corresponding with the string of letters within parentheses, may delete the left / right ( 72 # Test = " x Hello alexg " 73 is # V = test.lstrip (" x ") # output is: Hello alexg 74 # V = test.rstrip (" XG ") is output #: x Hello ALE 75 # Test = "xalexgdeea" # this is very interesting, worthy of study. 76 #test.lstrip = V ( "daxaeadedxddfasdfzx") 77 # # V = test.rstrip ( "XG") 78 # Print (V) 79 # TXT = ",,,,, ..... ssaaww Banana" # Delete all leading characters (spaces are to be deleted default leading characters) 80 # the X-txt.lstrip = ( ",. bnwasw") 81 # What print (x) # the result is not 82 83 # the Test = "alxe" 84 # v = test.isprintable () # judged as printable, with the proviso that there can not \ t \ n, which are not visible 85 # Print (V) # result is False or True 86 87 # Test = "axdel" 88 # test1 = "1325 * "# To replace with, it must be replaced with the same length of 89 # V = "alskdjf; lkjsd; lfkiena" 90 # m = str.maketrans (Test, test1) # maketrans and translate with use, mainly used to replace. 91 is # new_v = v.translate (m) 92 # Print (new_v) 93 94 Test = " kjdflkajdsfiejk " # split effect, the divided display element. 95 V = test.partition ( " D " ) # output ( 'kj', 'd' , 'flkajdsfiejk') according to a predetermined character from the left or from the right, only 2 times! 96 # v = test.rpartition ( "") # can not be null character can be a space. 97 # Print (V) # output ( '', '', ' kjdflkajdsfiejk' = Test "djskfhjhejujdsfh" 100 # V = test.split ( "J") # [ 'D', 'skfh', 'of He', 'U', 'DSFH'] as required to do the division from the left, but the elements will not be displayed. 101 # V = test.split ( "J",. 3) # [ 'D', 'skfh', 'of He', 'ujdsfh'] is divided according to requirements, but only the number of divisions defined by the following number) 102 # v = test.rsplit ( "j", 2) # [ 'djskfhjhe', 'u', 'dsfh'] as required from the right to do division, the number of divisions defined by the following figures. 103 104 # regex 105 # element if you want to divide, have their own decision. 106 # revisit later. 107 108 # segmentation, segmentation according newline only. 109 # the Test = "dafhiuh \ njwke \ ndjfej \ nhjmnjh" 110 # V test.splitlines = () # [ 'dafhiuh', 'jwke', 'djfej', 'hjmnjh'] newline is not displayed. 111 # V = test.splitlines (False) # [ 'dafhiuh', 'jwke', 'djfej', 'hjmnjh'] is not displayed newline 112 # V = test.splitlines (True) # [ 'dafhiuh \ n-', 'jwke \ n', 'djfej \ n', 'hjmnjh'] newline display 113 114 # Test = "dskbeil93" 115 # whether v = test.startswith ( "d") # character is determined to specify the beginning and gives results: & False True 1 16 # V = test.endswith ( ". 3") # determines whether the end of the specified character, and gives the result: & False True 117 1 18 119 # Test = "alQEFDcai" 120 # V = test.swapcase ( ) #ALqefdCAI case conversion (uppercase to lowercase, uppercase becomes lowercase)