= name " QJH " Print (name.capitalize ()) # will be capitalized QJH output // # Print (name.count ( "q") // QJH # Print (name.center (50, "-")) // # -. 1 # Print (name.endswith ( "S")) # what end Print (name.expandtabs (TabSize = 30)) # Print (name.find ( " D " )) Print (name.format ( = name ' qjhqqffd ' )) Print ( ' AD21 ' .isalnum ()) Print ( ' AD 'Kislf ()) Print ( ' . 1A ' .isdecimal ()) Print ( ' . 1A ' .isdigit ()) Print (( ' . 1A ' .isidentifier ())) # determines whether valid identifier Print ( ' 33.33 ' .isnumeric ()) Print ( ' My name IS ' .istitle ()) Print ( ' My name IS ' .isprintable ()) Print ( ' My name IS ' .isupper ()) Print ( ' + '.join(['1','2','3'])) print(name.ljust(50,'*')) print(name.rjust(50,'-')) print('Qjh'.lower()) //qjh print('qjh'.upper()) //QJH #print('qjh\n'.lstrip()) #print('\nqjh'.lstrip()) #print(' qjh\n'.strip()) print('---'.lstrip()) //--- p = str.maketrans("qdsjdsh",'1234567') print("qjhs".translate(p)) //1476 print('qjjh'.replace('j','J')) //qJJh print('qj h'.rfind('h')) //3 print('q+j+h+d+s+a'.split('s')) //['q+j+h+d+', '+a']
name.capitalize () capitalized name.casefold () all uppercase to lowercase name.center ( 50, " - " ) Output ' --------------------- ---------------------- of Li alex ' name.count ( ' lex ' ) lex statistical occurrences name.encode () format string encoded into bytes name .endswith ( " of Li " ) determines whether the string that ends of Li " Alex \ tLi " .expandtabs (10) outputs ' Alex of Li ' , the \ t converted into long spaces name.find ( ' a ' ) to find a, find returns its index can not be found or -1