Python string manipulation

Source: Internet
Author: User

Escape character (\)

Original string (preceded by quotation marks at the beginning of the string)

Sanchong a multiline string ("") in quotation marks

Multiline comment ("" "" "")

string subscript and Slice

The in and not in operators of a string (the first string < exact match, case-sensitive > whether in the second string)

Useful string methods:

Upper () *************** all letters in the original string are converted to uppercase

Lower () *************** all letters in the original string are converted to lowercase

Isupper () *********** returns a Boolean value

Islower () *********** returns a Boolean value

Isx String Method:

Isalpha () *************** contains only letters, not empty

Isalnum () *************** contains letters and numbers, non-empty

Isdecimal () *************** contains only numbers, not empty

Isspace () *************** contains spaces, tabs, and line breaks, not empty

Istitle () *************** contains only words that start with a capital letter and are followed by lowercase letters

StartsWith () *************** string starts with a character equal to another string

EndsWith () *************** string ends with a character equal to another string


Join () *************** connection string list

Split () *************** split string list


Rjust () *************** right Align

Ljust () *************** left-justified

Center () *************** Text Center


Strip () *************** Delete the beginning and end of the blank string

Rstrip () *************** Delete the blank string on the right

Lstrip () *************** Delete the left blank string


Pyperclip module Copy paste string

Copy ()

Paste ()


Python string manipulation

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.