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

Introduction to several methods of representing strings in Python

巴扎黑
巴扎黑Original
2017-09-07 09:48:302703browse

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;

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;

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;

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!

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