_yourname = "ruijie" yourname = input('yourname: ') if yourname == _yourname: print("nice") else: print("error")
1、一个=等于为变量赋值,两个==为运算符号中的等于;
2、if 后的条件语句要加冒号:;
3、if语句中一定要注意缩进的量级,只有在同一量级的语句才会被包括在if语句中。
while
1 age_of_oldboy=18
2
3 count=0
4 while count<3:
5 guss_age = int(input("guss_age:"))
6 if guss_age==age_of_oldboy:
7 print("you are ringt")
8 break
9 elif guss_age>age_of_oldboy: 10 print("think small") 11 else: 12 print("think big") 13 count+=1 14 if count==3: 15 continue_comfirm=input("do you want to keep guessing....") 16 if continue_comfirm != "n": 17 count=0
1、count =count+1 与cont+=1;
2、print'hello {0} i am {1}'.format('ruijie','cisco')
# hello ruijie i am cisco
官方推荐用的方式,%方式将会在后面的版本被淘汰