#-*-coding:utf-8-*- Line="l want watch movie with you."Print(Line.center (50))Print(Line.ljust (50))Print(Line.rjust (50))#Center string Centered#Ljust String Left#rjust characters in the right#Lstrip Remove whitespace characters to the left of a string#Rstrip Remove whitespace characters to the right of a string#strip delete whitespace characters at both ends of a stringWord="\ t \ I am a bird. \ r \ n"Print("==lstrip==")Print(Word.lstrip ())Print("===rstrip==")Print(Word.rstrip ())Print("==strip==")Print(Word.strip ())#whitespace characters include invisible characters such as spaces/n/tNword="Hello this a new world."Print("==partition==")#PartitionPrint(Nword.partition ("a"))#finds the specified string from left to right in the source string, finds the specified string to be cut, divides it into 3 parts, specifies the string before, and, after itself, the return value is a tuple#if the specified string does not exist in the source string, the result consists of the source string itself, which consists of two empty strings#rpartition to find the specified string from right to leftWline="hello \ n World"Print("==splitlines==")Print(Wline.splitlines ())#splitlines the row to return a list containing the rows as elementsPrint("==isalpha==")Print(Wline.isalpha ())#returns false because there are spaces, escape characters#Isalpha Determines whether all characters in a string are letters, the letter returns True, and the other returns falseNum="12233"Print("==isdigit==")Print(Num.isdigit ())#IsDigit Determines whether all characters in a string are numbers, returns True, and returns falseStr="sadfa213"Print("==isalnum==")Print(Str.isalnum ())#Isalnum Whether the string is only composed of numbers and letters, returns True, and the other returns falseSpace=" "Print("==isspace==")Print(Space.isspace ())#Isspace Determines if there are only spaces in the string, returns True, and returns falsePrint("==join==") Tstr="_"List1= ["AA","BB"]Print(Tstr.join (list1))#inserts the specified character after each character, forming a new string
Python string manipulation function two