python- data type - String - Common Operation

String common operations

  str.capitalize () first letter capitalized

  str.casefold () all lowercase become more powerful, you can also perform many locations  

  str.lower () becomes all lowercase

  str.center () with parameter string bracket width and the contents center, parameters representative of the length, the default blank filled, or filled with a character, optional

  str.count () parentheses parameters ( 'query character', query start position, end position) count the number of parameters that appear within brackets in the string

  str.encode coding

  str.decode decoding

  str.endswith () with parameters a parameter bracket ending

  str.startswith () with parameters in parentheses for the beginning of the parameter

  str.find () brackets with parameters based on index lookup to find the front to back, find the first after acquiring its position. ( 'Character query' query start position, end position) is not found -1   

  str.index () brackets with parameters look not found error function in accordance with the subscript supra Find

  str.format () parentheses formatting parameters placeholder string {name} as replacing a specified value

  str.format_map brackets with parameters passed in the value format () function is a dictionary format supra

  str.isalnum () determines whether a string contains only letters and numbers are not False Ture

Guess you like

Origin www.cnblogs.com/069527qwer/p/11968699.html