String Basics 1

Source: Internet
Author: User

# Capitalize output first letter capitalization
# test= ' LeI '
# v=test.capitalize ()
# print (v)

# casefold Output all lowercase (special language can also, with less)
# Lower output full lowercase

# Center Center can fill fill only single-character (padding optional)
# test= ' Lei '
# V=test.center (20, ' * ')
# print (v)
#********lei*********

# Count statistics appear after the number of characters can be added range
# test= ' Leileileilei '
# V=test.count (' l ', 5,8)
# print (v)
# 1

# EndsWith StartsWith Judging the beginning and end of the range can be added after
# test= ' Leio '
# v1=test.endswith (' io ')
# v2=test.startswith (' Le ')
# Print (V1,V2)
# True True

# Find the first post-output position from the beginning, add range 1 not found
# test = ' Leilei '
# v = test.find (' il ')
# print (v)
# 2

#index can not find an error, use Find not Error List in the index position to find the sequence

# Format formatted to replace a string placeholder with the specified value
# test = ' I am {name} '
# Print (test)
# v = test.format (name= ' lei ')
# print (v)
#i am {Name}
# I am Lei

# test = ' I am {name},age{a} '
# V1 = Test.format (name= ' lei ', a=10)
# v2 = test.format_map ({' name ': ' Lei ', ' a ': 22})
# Print (V1,V2)
# I am lei,age10 I am lei,age22

# Isalnum judgment string contains numbers and letters, and other special characters are false
# test = ' asds12324 '
# v = test.isalnum ()
# print (v)
#Ture

String Basics 1

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.