1. Variable "_"
In interactive mode, the value of the last expression is assigned to the variable._. In this way, we can use it as a desktop calculator for continuous computing, for example:
>>>Tax = 12.5 / 100>>>Price = 100.50>>>Price * Tax12.5625>>>Price + _113.0625>>>Round(_, 2)113.06
This variable is read-only for users. Don't try to assign a value to it-you will only create an independent local variable with the same name, which shields the magic effect of the built-in variables of the system.
2. Three quotation marks
A string can be enclosed in one pair of three quotation marks:'"""'Or'''''. There is no need to escape the lines in the three quotation marks. They are already included in the string.
Print("""\Usage: thingy [Options]-H display this usage message-H hostname to connect""")
The output is as follows:
Usage: thingy [Options]-H display this usage message-H hostname to connect
3. original string
If we generate an "original" string,\ NThe sequence is not escaped, And the backslash at the end of the line and the line break in the source code are all part of the data in the string. Therefore, the following example:
Hello = R "this is a rather long string containing \ n\Several lines of text much as you wowould do in C ."Print(Hello)
Printed:
This is a rather long string containing \ n \ several lines of text much as you wowould do in C.
4. "+" and "*" of the string "*"
The string can be+Operator join (stick together), can be*Repeat:
>>>Word = 'Help' + 'A'>>>Word'Helpa'>>>'<' + Word*5 + '>''<Helpahelpahelpahelpahelpa>'