In Python, strings can be enclosed in single quotes or double quotes. These two methods are equivalent. However, in PHP, some single quotes and double quotes are different. Although they represent strings, But single quotes in php are parsed faster than double quotes.
If you need to represent a string object in python, there is no difference between single quotes and double quotes.
Vice versa. This is why python allows two methods. In practical applications, python single quotes and python double quotes are used more frequently. With these two representation methods, there is no need to use escape characters all the time.
For example, in python:
a = 'i love 'laowang python''
print a
and
a = "i love 'laowang python'"
print a have the same result.
Python triple quotes are used to enter multi-line text, which means that the content entered between the triple quotes will be retained as is. The single numbers and double quotes do not need to be escaped, and the invisible characters such as n and t are not required. will be retained. The advantage of this is that you can replace some multi-line text.
For example:
content = '''wwwfefefefefse%(name)s is
haha,he age is %(age)s'''
c = content % {'name':'pythoner','age': '20 '}
The result of print c is:
wwwfefefefefsepythoner is
haha,he age is 20