0 Fundamentals python-7.1 String Introduction and common functions in Python

Source: Internet
Author: User

In Python, the string becomes a powerful set of processing tools, and he is immutable, meaning that the string contains the order of characters and characters, which he cannot modify

The string is a slightly larger category of objects that we need to learn later-the first representation of a sequence

In the section of the string about the operation of the sequence, the following list is the same as the tuple

Some of the operations and functions commonly used in strings

Operation Explain
S= " Empty string
s= "ABC ' d" Double quotes and single quotes are the same
s= ' abc\n ' Escape sequences, use variables to fully display characters,
Only use the print function to show escape
S= "" "AAAAA" "" Sanchong Quote String block
S=r ' \temp\spam ' Raw string
S=b ' abc ' Python 3.x byte string
S=u ' BAC ' Unicode string
S1+s2 Merge
S*3 Repeat
S[i] Index
S[I:J] Sharding
Len (s) Request length
"A%s parrot"% kind String formatting expressions
"A {0} parrot". Format (Kind) Method of String formatting
S.find (' xxx ') Search
S.rstrip () Remove spaces
S.replace (' xxx ', ' xxx ') Replace
S.endswith (' xxx ') End With XXX
' xxx '. Join (Strlist) Entry and exit separators
S.encode (' latin-1 ') Change code
For x in S:print (x) Iteration
' xxx ' in S Member relationships
[C*2 for C in S] Member relationships
Map (ord,s) Member relationships




Right here, thank you.

------------------------------------------------------------------

Click to jump 0 basic python-Catalogue


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

0 Fundamentals python-7.1 String Introduction and common functions in Python

Related Article

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.