python学习笔记day01_07 流程控制语句

用户交互(input)

举一个用户交互的例子,当你登录博客园时,需要输入用户名和密码(这一步其实就是用户交互),前段把用户名,密码传给后端等

1.等待用户输入;

2.将输入的内容交给赋值号=左边的变量

3.另外,input的结果一定是str类型:

    后边如果想转化成数字类型,可以用eval(input("请输入您的年龄:"))

if 条件语句(有三种)

单选:

if 5>4:
    print("you are right")
print("end")

两个选择:

if 5>4:
    print("5>4")
else:
    print("5<4")

多个选择:

number=int(input("please input a number:"))
if number == 1:
    print("wat you input is 1")
elif number == 2:
    print("what you input is 2")
elif number == 3:
    print("what you input is 3")
else:
    print("input Error")
    
talk is cheap,show me the code
原文地址:https://www.cnblogs.com/xuanxuanlove/p/9455095.html