Home > Backend Development > Python Tutorial > Introduction to several methods of representing strings in Python

Introduction to several methods of representing strings in Python

巴扎黑
Release: 2017-09-07 09:48:30
Original
2809 people have browsed it

This article mainly introduces relevant information on the three methods of representing strings in Python. Friends who need it can refer to it

There are three ways to represent strings in Python

The first method

Use single quotes (')

Use single quotes to represent a string, for example:


##

str='this is string'; 
print str;
Copy after login

Second method

Use double quotes (“)

The usage of strings in double quotes is exactly the same as that in single quotes ,

For example:


##

str=”this is string”; 
print str;
Copy after login

The third method

Use triple quotes ("' )

Use triple quotes to represent multi-line strings. You can freely use single quotes and double quotes within the triple quotes,

For example:


str=”'this is string 
this is pythod string 
this is string”' 
print str;
Copy after login

The above is the detailed content of Introduction to several methods of representing strings in Python. 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