Summary of key points of python strings and key points of python strings

Source: Internet
Author: User

Summary of key points of python strings and key points of python 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.

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.