Python string basic operation

Source: Internet
Author: User

Python string basic operation

1, judge is not a valid identifier Isidentifier

Name= "ABC" Print (Name.isidentifier ()) printing result true
2, the first letter capital capitalize
Name= ' abc ' Print (Name.capitalize ()) printed results ABC
3. Counting count
Name= ' abc ' Print (Name.count ("a")) printing Results 1
4, located in the center, with-to supplement the center
Name= ' abc ' Print (Name.center (50, "-")) printing results-----------------------ABC------------------------
5, judge whether to end with C EndsWith
Name= ' abc ' Print (Name.endswith ("C")) printing result true
6. Replace the carriage return with a blank expandtabs
Name = "A\TBC" Print (Name.expandtabs (tabsize=10)) results a         BC
7. View a word Poute find
Name= ' abc ' Print (Name.find (' C ')) printing results 2
8. Lowercase lower characters
Print ("Xiedi". Lower ()) printing results Xiedi
9. Capitalize the characters Upper                                                                                                                                      
Print ("Xiedi". Upper ()) Xiedi

Python string basic operation

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.