Day4-python Base 4 string manipulation

Source: Internet
Author: User

1. String usage

1Name ='Daniel'2 3 Print(Name.capitalize ())#Capitalize first letter4>>>Daniel5 Print(Name.count ('a'))#statistics the specified character6>>>17 Print(Name.center (50,'-'))#print a total of 50 characters, not enough to use-instead, put the name in the middle8>>>----------------------Daniel----------------------9 Print(Name.endswith ('El'))#Judging if the end is ' el 'Ten>>>True One Print(Name.expandtabs (tabsize=30))#if you enter \ t (tab) in front of a character, 30 spaces are automatically printed A>>>Daniel - Print(Name.find ('a'))#find the location where the characters are made ->>>1 theNames ='{Name} is {year} years old'     - Print(Names.format (name='Daniel', year=18))#Assigning a value to a temporary variable ->>>daniel is18years old - Print(Name.index ('D'))#gets the subscript for the specified character +>>>0 - Print(Name.isdigit ())#determine if a variable is a certificate +>>>flase A Print(Name.isalnum ())#determine if the variable is an Arabic character (contains numbers and English) at>>>True - Print(Name.isalpha ())#determine if a variable is a plain English character ->>>True - Print(Name.isdecimal ())#judgment variable is 10 binary digits ->>>False - Print(Name.isidentifier ())#judgment is not a valid variable name in>>>True - Print(Name.islower ())#to determine if a variable is lowercase to>>>True + Print(Name.isnumeric ())#determine if a variable has only a number ->>>False the Print(Name.istitle ())#determine if a variable is capitalized (per word) *>>>False $ Print(Name.isprintable ())#determine if you can printPanax Notoginseng>>>True - Print(Name.isupper ())#determine if all are uppercase the>>>False + Print('+'. Join (['1','2','3']))#Add something in the list to ' + ', not str, if the number is ' put in ' A>>>1+2+3 the Print(Name.ljust (50,'*'))#Print 50 characters, not enough to use * instead of on the right +>>>daniel******************************************** - Print(Name.lrjust (50,'*'))#contrary to the above $ Print(Name.lower ())#turn uppercase to lowercase $>>>Daniel - Print(Name.upper ())#turn lowercase to uppercase ->>>DANIEL the Print('\ndanile'. Lstrip)#Delete the left space - Print('daniel\n'. Rstrip)#Delete the space on the rightWuyi Print('\ndaniel\n'. Strip)#Delete all the spaces the Print('danieldd'. replace ('D','D', 1))#replacing the following 1 means replacing only the first one ->>>danieldd Wu Print('Daniel DD'. RFind ('D'))#Locate the rightmost subscript of the specified value ->>>8 About Print('Daniel 1 2 3 4'. Split ())#divides into a list using the specified character as a delimiter, and the default is a space $>>>['Daniel','1','2','3','4'] - Print('Daniel 1 2 3 4'. Splitlines ())#as above, different systems can be identified - Print('Dianiel'. Swapcase ())#uppercase to lowercase ->>>daniel

Day4-python Base 4 string manipulation

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.