Python in Strip, StartsWith, EndsWith

Source: Internet
Author: User

Strip (RM) is used to delete white space characters within an element:

RM corresponds to the element for which you want to remove whitespace, and when RM is empty (strip ()), the whitespace of all elements is removed

StartsWith, endswith the element used to find the beginning or end condition

Example:

1Li = ["Alec","Aric","Alex","Tony","Rain"]2Tu = ("Alec","Aric","Alex","Tony","Rain") 3DIC = {'K1':"Alex",'K2':'Aric',"K3":"Alex","K4":"Tony"}4  forIinchLi:5b =I.strip ()6     if(B.startswith ("a")orB.startswith ("A")) andB.endswith ("C"):7         Print (b)8 9  forIinchTu:Tenb =I.strip () One     if(B.startswith ("a")orB.startswith ("A")) andB.endswith ("C"): A         Print (b) -          -  forIinchDIC: theb =Dic[i].strip () -     if(B.startswith ("a")orB.startswith ("A")) andB.endswith ("C"): -         Print (b

The above code: finds all elements that start with a or a and ends with C, and outputs

Output Result:

Alecaricalecaricaric

Python in Strip, StartsWith, EndsWith

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.