Detailed explanation of the key points of Python string summary

高洛峰
Release: 2017-03-16 17:11:44
Original
1489 people have browsed it

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!