Share the key points of the Python string,

Source: Internet
Author: User

Share the key points of the Python string,

A string is the most common data type in Python. We can use quotation marks to create strings. The key points of a python string are as follows:

1. Some characters separated by quotation marks

You can see that the string is a data type of Python. It can be seen that it is a character array or a continuous character set combination between Python single quotes or double quotes. The most common quotation marks in python are ('') and (""). The two functions are the same. The actual content of a string is a character between the quotation marks and does not contain the quotation marks themselves.

2. The separators are not allowed.

A string is a unique literal Character Sequence type. However, the character itself is not a type, so the string is the most basic unit of character storage operations.

3. the string formatting operator (%) provides functions similar to printf ()

The string formatting operator provides a flexible way to create custom strings Based on Multiple output types. It provides interfaces similar to C/C ++ formatting operations.

4. Three quotation marks

Three quotation marks can contain special characters such as line breaks, carriage returns, and tab keys. Three single quotation marks (''') or double quotation marks ("""""")

5. The original string uses its original intent for each special character

This is very useful in defining regular expressions.

6. the python string does not end with NUL or '\ 0'.

In C, the string '\ 0' is used as the terminator to prevent cross-border attacks. But in python, no, you do not need to worry about whether the terminator has been added. The string value contains what you define, nothing else.

The above content is a summary of all the key points of the Python string. I hope you will like it.

Articles you may be interested in:
  • Python string replacement example
  • Convert a dictionary to its json string in python
  • Python executes the string expression function (eval exec execfile)
  • Example of using MD5 to encrypt a string in Python
  • Python string sorting method
  • Summary of N methods for python string connection
  • Using python to sort string lists with case-insensitive characters
  • Python's method of determining whether a string is a pure number
  • Python string Replacement Methods
  • Python method for determining whether a string contains a substring
  • How to format strings using the format function in Python
  • Python converts a string to an array
  • How to convert strings and dates 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.