Home > Article > Backend Development > Introduction to several methods of representing strings in Python
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;
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!