1.序列解包
2.bool型
3.if /for in /while语句块
4.exec pass del语句
>>> #序列的解包
>>> x,y,z=1,2,3
>>> y
2
>>> z
3
>>> v=1,2,3
>>> v
(1, 2, 3)
>>> a,b,c=v
>>> b
2
>>> s={'one':1,'two':2}
>>> key,val=s.popitem()
>>> key
'one'
>>> val
1
>>> #语句块 :
>>> x=10
>>> while x>0:
x=x-1
print(x)
9
8
7
6
5
4
3
2
1
0
>>> #布尔型变量
>>> 0
0
>>> bool(0)
False
>>> bool({})
False
>>> bool([])
False
>>> bool(())
False
>>> bool(None)
False
>>> bool('')
False
>>> False==0
True
>>> True==1
True
>>> #if
>>> x=10
>>> if x>1:
print(x)
10
#断言
>>> x=10
>>> if x>1:
assert x==6
Traceback (most recent call last):
File "<pyshell#8>", line 2, in <module>
assert x==6
AssertionError
#for
>>> for word in words:
print("word:",word)
word: one
word: two
word: three
word: four
>>> for i in range(-1,-10,-1):
print(i)
-1
-2
-3
-4
-5
-6
-7
-8
-9
>>>
>>> keys2={"one":1,'two':2}
>>> for i in keys2:
print(i,keys2[i])
one 1
two 2
>>> names=['name','beth','geo','damon']
>>> ages=[1,2,3,4]
>>> zip(names,ages)
<zip object at 0x0000000003590C88>
>>> list(zip(names,ages))
[('name', 1), ('beth', 2), ('geo', 3), ('damon', 4)]
>>> pass
>>>
>>>
>>>
>>> pass
>>> x=10
>>> del x
>>> x
Traceback (most recent call last):
File "<pyshell#51>", line 1, in <module>
x
NameError: name 'x' is not defined
>>>