and del from not while as elif global or with assert else if pass yield break except import print class exec in raise continue finally is return def for lambda try
>>> a = 2 >>> b = 3 >>> if a < 3 and b > 2: ... print('a小于3且b大于2') ... a小于3且b大于2
>>> num = 3 >>> if num == 1: ... print('num的值为1') ... elif num == 2: ... print('num的值为2') ... else: ... print('num的值为其它值') ... num的值为其它值
>>> i = 0 >>> while i < 5: ... i += 1 ... if i == 3: ... break ... print(i) ... 1 2
>>> def add(x, y): ... return x + y ... >>> result = add(3, 5) >>> print(result) 8
>>> x = 10 >>> def func(): ... global x ... x += 10 ... >>> print('x的值为:', x) 10 >>> func() >>> print('x的值为:', x) 20
>>> def outer_func(): ... x = 10 ... def inner_func(): ... nonlocal x ... x += 10 ... print('x的值为:', x) ... inner_func() ... print('x的值为:', x) ... >>> outer_func() x的值为: 20 x的值为: 20
标签: seo