Related methods for "Python string" string (ii)

Source: Internet
Author: User

Finds the first index position of an element text.find () can have a start and end position find (' ex ', 3,6)

# find the index position of an element ' Alexalex '  = text.find ('ex')print(ret)
2

A format operation that replaces a placeholder in a string with a specified value
# A format operation that replaces a placeholder in a string with a specified value ' My name is: {name}, my age is: {ages} ' ret=text.format (name='Alex', age=15)print(ret)
My name is: Alex, my age is: 15

Equivalent: Text.format_map ({' name ': ' Alet ', ' age ': 19})

Determines whether a string contains only numbers and letters Isalnum ()

# determine if a string contains only numbers and letters
test1='abc123'test2='abc123+-*'ret1= test1.isalnum () ret2=test2.isalnum ()print(Ret1,ret2)
True False

  

Related methods for "Python string" string (ii)

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.