Two ways to enter single quotes in Python
How to enter single quotes in the Python string str object, for example, if you want to enter English: This's How to enter single quotes in Python? Two methods are introduced here, as follows:
- Use double quotes to define a Python string, and then wrap it with single quotes. Of course, if it is not troublesome, you can also use a multi-line string, that is, six consecutive double quotes to wrap it, such as """ ......""", single quotes including single quotes are not allowed;
- Use Python's single quote escape character "\" to achieve this;
Python input single quote example code
>>> x = "This's Python blog!"
>>> x
"This's Python blog!"
>>> y = "使用转义字符\'来输出单引号"
>>> y
"使用转义字符'来输出单引号"
>>> z = """这本是多行字符串,这里也可以直接输入单引号'...'"""
>>> z
"这本是多行字符串,这里也可以直接输入单引号'...'"
Original text: How to type single quotes in python, two input methods
Disclaimer: Content is for reference only.