#-*-coding:utf-8-*- ''' The use of format %s The use of %s ''' name = input("Input your name:") age = input("Input your age:") height = input("Input your height:") msg = '我叫%s,今年%s 高%s'%(name,age,height) print(msg)
#-*-coding:utf-8-*- ''' The use of format %s The use of %s ''' name = input("Input your name:") age = input("Input your age:") job = input("Input your work:") hobbie = input("Input your hobbie:") msg = '''---------------------index of %s ------------- Name : %s Age : %d Job : %s Hobbie : %s ---------------------end --------------------------''' %(name,name,int(age),job,hobbie) print(msg)
二、 三次登录程序优化
#-*-coding:utf-8-*- ''' ''' i=0 username = 'bowen' password = '123' while i<3: name = input('Input your name:') pwd = input('Input your password:') if username == name and password == pwd: print("Congrations,Login in Success!") break else: print('failed to login in,you still have %d times to try ' %(2-i)) if(2-i)==0: result = input("You still want to try?Y or N") if result == 'Y': i==0 continue i +=1 else:print('fuck you!')
这是对昨天的那个while程序的优化。输入三次错误的。最后不管是输入Y还是N,都会弹出fuck you