mirror of https://github.com/python/cpython
#1530012: move TQS section before raw strings.
This commit is contained in:
parent
1a1158f955
commit
186188d89d
|
@ -199,21 +199,6 @@ the following::
|
||||||
several lines of text just as you would do in C.
|
several lines of text just as you would do in C.
|
||||||
Note that whitespace at the beginning of the line is significant.
|
Note that whitespace at the beginning of the line is significant.
|
||||||
|
|
||||||
If we make the string literal a "raw" string, however, the ``\n`` sequences are
|
|
||||||
not converted to newlines, but the backslash at the end of the line, and the
|
|
||||||
newline character in the source, are both included in the string as data. Thus,
|
|
||||||
the example::
|
|
||||||
|
|
||||||
hello = r"This is a rather long string containing\n\
|
|
||||||
several lines of text much as you would do in C."
|
|
||||||
|
|
||||||
print hello
|
|
||||||
|
|
||||||
would print::
|
|
||||||
|
|
||||||
This is a rather long string containing\n\
|
|
||||||
several lines of text much as you would do in C.
|
|
||||||
|
|
||||||
Or, strings can be surrounded in a pair of matching triple-quotes: ``"""`` or
|
Or, strings can be surrounded in a pair of matching triple-quotes: ``"""`` or
|
||||||
``'''``. End of lines do not need to be escaped when using triple-quotes, but
|
``'''``. End of lines do not need to be escaped when using triple-quotes, but
|
||||||
they will be included in the string. ::
|
they will be included in the string. ::
|
||||||
|
@ -230,6 +215,20 @@ produces the following output::
|
||||||
-h Display this usage message
|
-h Display this usage message
|
||||||
-H hostname Hostname to connect to
|
-H hostname Hostname to connect to
|
||||||
|
|
||||||
|
If we make the string literal a "raw" string, ``\n`` sequences are not converted
|
||||||
|
to newlines, but the backslash at the end of the line, and the newline character
|
||||||
|
in the source, are both included in the string as data. Thus, the example::
|
||||||
|
|
||||||
|
hello = r"This is a rather long string containing\n\
|
||||||
|
several lines of text much as you would do in C."
|
||||||
|
|
||||||
|
print hello
|
||||||
|
|
||||||
|
would print::
|
||||||
|
|
||||||
|
This is a rather long string containing\n\
|
||||||
|
several lines of text much as you would do in C.
|
||||||
|
|
||||||
The interpreter prints the result of string operations in the same way as they
|
The interpreter prints the result of string operations in the same way as they
|
||||||
are typed for input: inside quotes, and with quotes and other funny characters
|
are typed for input: inside quotes, and with quotes and other funny characters
|
||||||
escaped by backslashes, to show the precise value. The string is enclosed in
|
escaped by backslashes, to show the precise value. The string is enclosed in
|
||||||
|
|
Loading…
Reference in New Issue