How to type python triple quotes: 1. Directly use three backslashes to escape; 2. Create a new module and enter [a = "\""print(a a a)] in the module; 3 , use the ord function to obtain the ASCII encoding value of a character.
The operating environment of this tutorial: Windows 7 system, python version 3.9, DELL G3 computer.
How to type python triple quotes:
1. The first method is relatively simple, just use three backslashes to escape, that is:
print("\"\"\"");
Because \" represents a quotation mark, then three consecutive \" are naturally triple quotation marks.
2. The second method is a little more verbose. Print three quotes through variables and create a module through "File" -> "New File" in the menu bar.
3. Enter in the module:
a = "\""print(a + a + a)
Confirm, save, and then run.
4. The effect is the same as using print("\"\"\"");
directly on the command line.
5. The third method is a bit circuitous, printing through character encoding. Because any information is saved in the form of data in the computer, strings are no exception. , since it is data, it must have a value, and the same is true for characters. In python, you can use the ord function to get the ASCII encoding value of a character. For example, ord("\"") can get the ASCII encoding of the quotation mark, which is 34.
6. Then you can use the chr function to convert the numeric value to the character corresponding to the value. We save it through a variable and then print it three times in a row through print, or directly Add the variables three times and print them, like this:
>>> a = chr(34)>>> s=a + a + a>>> print(s)"""
Related free learning recommendations: python video tutorial
The above is the detailed content of How to type three quotes in python. For more information, please follow other related articles on the PHP Chinese website!