Python syntax base (2)

First, the flow control statements

if the keyword

#格式如下
if 条件 :
    内容
  • if branch statement
if 3>2:
  • if else statements
if 3>2:
else :
  • if if elif statement
if 5>4:
elif 4>3:
elif 3>2:
else:
  • if nested statements
if 3<5:
    if 4<5
    print("这就是循环")

Second, the loop

while syntax

whil keyword

#语法格式如下
 while 条件 :
    循环体

1break is out of the whole cycle
2.continue out of this cycle, the next cycle continues
3. You can use an if statement loop control

for loop syntax

i variable for keywords in the keyword to iterate objects:

#语法格式如下
for   变量  in 迭代对象 :
    循环体

Third, formatted output

Fourth, the initial character encoding

Fifth, operators know

Guess you like

Origin www.cnblogs.com/SkyRabbit/p/11202881.html