Home  >  Article  >  Backend Development  >  Detailed explanation of the key points of Python string summary

Detailed explanation of the key points of Python string summary

高洛峰
高洛峰Original
2017-03-16 17:11:441532browse

PythonStringThe key points are as follows:

1. Some quotation mark separated characters

You can look at the string Out is a data type of Python, a character array or a continuous character set between Python single quotes or double quotes. The most commonly used quotation marks in python are ('') and (""). The functionality of both is the same, the actual content of the string is the characters between the quotes, not the quotes themselves.

2. InseparableCharacter type

String is the only literal character sequence type. However, characters themselves are not a type, so strings are the most basic unit of character storage operations.

3. String formatting Operator (%) provides functions similar to printf()

String formatting operator provides A flexible way to create custom strings based on multiple output types, it provides an interface similar to C/C++ formatting operations.

4. Triple quotation marks

can contain special characters such as line feed, carriage return or tab key. Triple quotes are actually three single quotes (''' ''') or double quotes (""" """) on both sides

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

This is very useful in defining regular expressions.

6.Python strings are not terminated by NUL or '\0'

C language strings use '\0' as the terminator to prevent Cross the line. But in python, no, you don't need to worry about whether the terminator has been added at all. The string value contains what you defined and nothing else.


The above is the detailed content of Detailed explanation of the key points of Python string summary. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn