A list of Python string manipulation functions

Source: Internet
Author: User
Tags uppercase character

S.strip (chars) s.find (x,start,end) s.index (x.start,end)#see above;S.format ()#see above;S.partition (x)#see above;S.replace (X,y,n)#replace x with Y, optional n means maximum substitution n times;S.split (X,n)#divide up to n times, S.rsplit () splits from the right;S.splitlines (f)#returns a list that is split at the newline character and strips the newline character (unless F is true);S.count (X,start,end)#CountS.join (seq)#returns the result that each item of SEQ is concatenated with S, and s can be empty;S.capitalize ()#capitalize the first letter of the string;S.lower ()#changes the character in s to lowercase;S.upper ()#returns the capitalized version;S.title ()#capitalize the first letter of each word;S.swapcase ()#make uppercase lowercase, lowercase to uppercase;S.islower ()#returns True if S has at least one lowercase character and all lowercase characters are lowercase;S.isupper ()#returns True if S has at least one uppercase character and all uppercase characters are uppercase;S.istitle ()#returns True if S is a non-empty first-letter uppercase string;S.zfill (W)#returns a copy of S, if shorter than W, from the beginning with 0 supplement, so that the length and W;S.center (Width,char)#returns a string with the width of the center length of s, or padding with an optional argument char or a space if one is available, such as Width<len (s), which returns the entire S;S.ljust (Width,char)#Ibid., left-aligned;S.rjust (Width,char)#Ibid., right alignment;S.encode (Endoding,err)#returns a Bytes object that represents the string using the default encoding format or the specified encoding format, and handles errors based on the optional err parameter;S.endswith (X,start,end)#Returns true if End with X, otherwise false;S.startswith (X,start,end)#returns True if it starts with X;S.expandtabbs (size)#returns a copy of S, where the tabs are replaced with 8 or a specified number of spaces;S.isalnum ()#Determine whether it is all alphanumeric and not empty;S.isalpha ()#judge whether it is all letters and not empty;S.isdecimal ()#determines whether each character is a number with a base of 10 Unicode, and whether all characters are decimal charactersS.isdigit ()#determine if each character is an ASCII number;S.isidentifier ()#to determine if it is not emptyS.isnumeric ()#determines whether each character is a numeric Unicode character Fu Yingfi null;S.isprintable ()#determines whether each character is printable and not empty;S.isspace ()#determines whether each character is a blank character;S.maketrans ()#make a table of translation mappingsS.translate ()#translate input into output according to mapping table
View Code

A list of Python string manipulation functions

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.