#"""学习和测试条件控制(单独使用和嵌套使用)"""
#在prompt和jupyter中多行注释都无效#测试单独使用name = input("place input you name : ")#默认传入的是stringmid = input("place input you age : ")if mid.isdigit(): #判断是否为数字 age = int(mid) #转换为int ,否则直接使用if age <= 18:报错,报错信息:TypeError: '<=' not supported between instances of 'str' and 'int'else: while not mid.isdigit(): #在条件满足时一直执行while内部的代码块,直到条件不满足时跳出循环,执行下面的代码 mid = input("place input you age : ") age = int(mid)if(name == "zhangsan"): #带括号不报错,不建议使用 print("Hello " + name)if name == "zhangsan": print("Hello " + name)elif name == "": name = input("place again input you name : ") #单独使用弊端:不能二次验证 print("Hello " + name)else: print("who you are !")#测试嵌套if name == "zhangsan": if age <= 18: print(name + "is a children !") elif age >= 60: print("time is flying !") age = age - 60;print("Hello " + name + " you age is back to " + str(age)) #上面已经转为int,不能进行直接字符串拼接,报错信息:TypeError: must be str, not intelif name == "": name = input("place again input you name : ") while name == "": #在条件满足时一直执行while内部的代码块,直到条件不满足时跳出循环,执行下面的代码 name = input("you input is null,place again input you name : ") print("Hello " + name)else: print("who you are !")结果: