How to enter single quotes in python

Release: 2019-07-06 15:01:21
Original
15175 people have browsed it

How to enter single quotes in python

When I use single quotes to represent a string, and there are single quotes in the string, we can represent these single quotes by escaping characters. If you want to represent the string Let's go, it must be like this:
s4 = 'Let\'s go',
There is a ' in the string, and the string is represented by ', so you need to use it at this time Escape character \ , if there are a lot of escape characters in the string, it will look very messy. Python also solves this problem very well, as follows:
s5 = "Let's go"  
python knows you " is used to represent a string, so python treats the single quotes in the string as ordinary characters. Isn't it very simple?
The same is true for double quotes. Here is an example
s6 = 'I really like "python"!'
This is why both single quotes and double quotes can represent strings.

For more Python-related technical articles, please visit Python TutorialColumn for learning!

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