PRint related
Print prints multiple expressions, as long as they are separated by commas, and a space is inserted between each parameter in the result, using + to avoid spaces, such as
>>> print ' Age: ', 42
Age:42
>>> print ' hello ' + ', ' + ' world '
Hello,world
Add a comma at the end of the print statement, and the next statement will be printed on the same line as the previous statement, such as
print ' Hello ', print ' world '
Results
>>>
Hello World
Import related
From Sometmodule import Somefunc,anotherfunc,yetanotherfunc
From somemodule Import *--all functions in the import module
Import Somemoudle as Othermodulename--take individual names for modules
Form Somemodule Import SomeFunc ad otherfuncname--Take an individual name for the imported function
Assignment correlation
Sequence unpacking or optional generation of unpacking--the sequence of multiple values is unpacked and then placed in the sequence of variables, as
>>> scoundrel = {' name ': ' Robin ', ' firlfriend ': ' Marion '}
>>> Key,value = Scoundrel.popitem ()
>>> Key
' Firlfriend '
>>> value
' Marion '
Chained assignment-A shortcut that assigns the same value to multiple variables, such as
X=y=somefunction ()
Increment assignment--place the expression operator on the left side of the assignment operator =, as
x + = 1
Statement block
The colon (:) is used to identify the beginning of the statement block, and each statement in the block is indented (the indent is the same). When you fall back to the same indent as an already closed block, it means that the current block is closed.
Three-person line
Pass--The program doesn't have to do anything.
Del-Deletes the object without affecting the value, such as
>>> x = y = [+]
>>> y[1] = ' P '
>>> y
[1, ' P ']
>>> x
[1, ' P ']
>>> del X
>>> x
Traceback (most recent):
File "<pyshell#51>", line 1, in <module>
X
Nameerror:name ' x ' is not defined
>>> y
[1, ' P ']
EXEC--A statement that executes a string
>>> exec ("print ' Hello, world! '")
Hello, world!.
Eval--To find the value of an expression
>>> eval ("4 + 56")
60
The above is the "Basic Python Tutorial" notes of the other statement 1 content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!