How to type single quotes in python

silencement
Release: 2019-05-22 13:42:59
Original
28793 people have browsed it

How to enter single quotes in Python?

How to type single quotes in python

Sometimes when we print a string to the screen, the string may contain single quotes. How to achieve this? Two solutions

The first one: put single quotes inside double quotes

For example

print("H's my good friend!")

print("I really like 'python'!")

Output result

How to type single quotes in python

Through the above example, you can see that single quotes have been used by us

Second: Use escape characters

Python itself uses \ to escape some special characters, especially when quotation marks are added to the string

For example

print('H\'s my good friend!')

print('I really like \'python\'!')

Output result

How to type single quotes in python

The above is the detailed content of How to type single quotes 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