python单引号(‘)、双引号(“)、三引号(”’,”””)

python对字符串的表示方法比c更有灵活性,但是也更难理解。

为了不在使用和查看代码的过程中混淆单引号(‘)、双引号(“)和三引号(’‘,”),要知道如何使用它们,有什么区别。

[En]

In order not to confuse single quotation marks (‘), double quotation marks (“), and triple quotation marks (”,”) in the process of using and looking at the code, know how to use them, and what is the difference.

进行了以下实验。

[En]

The following experiments were carried out.

结果如下:

从上面四个小实验可以看出,这些引号都是用来表示字符串和对字符串中的字符进行转义的。它们之间的主要区别是它们是否可以显示单引号和双引号以及多行而不转义。

[En]

From the above four small experiments, we can see that these quotation marks are all used to represent the string and escape the characters in the string. The main difference between them is whether they can display single and double quotation marks and multiple lines without escape.

不转义字符串

上述表示都是转义的,那么如何实现非转义的表示字符。

[En]

The above representations are escaped, so how to achieve unescaped representation characters.

在字符串前加一个r即可。

Original: https://www.cnblogs.com/chenhuan001/p/8006017.html
Author: chenhuan001
Title: python单引号(‘)、双引号(“)、三引号(”’,”””)

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/7809/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

最近整理资源【免费获取】:   👉 程序员最新必读书单  | 👏 互联网各方向面试题下载 | ✌️计算机核心资源汇总