1 # Author:JiangQing 2 # !/usr/bin/env python 3 # -*- coding:utf-8 -*- 4 import getpass 5 6 """ 7 #变量 8 name1 = "JiangQing" 9 name2 = name1 10 name1 = "JiaXin" 11 print("Lover :",name1,"love",name2) 12 13 msg1 = 'Love JIAXIN' 14 msg2 = '''name1 = "JiangQing" 15 name2 = name1 16 name1 = "JiaXin" 17 print("Lover :",name1,"love",name2) 18 ''' 19 print(msg1) 20 """ 21 22 23 """ 24 # 输入/输出 25 #输入 26 name = input("Name:") 27 age = int(input("Age:")) 28 #print(type(age)) 29 #print(type(str(age))) 30 job = input("Job:") 31 wife = input("Wife:") 32 #格式化输出 33 info1 = ''' 34 ---------- info of %s ---------- 35 Name:%s 36 Age:%d 37 Job:%s 38 Wife:%s 39 ''' % (name,name,age,job,wife) 40 41 info2 = ''' 42 ---------- info of {_name} ---------- 43 Name:{_name} 44 Age:{_age} 45 Job:{_job} 46 Wife:{_wife} 47 '''.format(_name=name,_age=age,_job=job,_wife=wife) 48 49 info2 = ''' 50 ---------- info of {0} ---------- 51 Name:{0} 52 Age:{1} 53 Job:{2} 54 Wife:{3} 55 '''.format(name,age,job,wife) 56 57 print(info2) 58 """ 59 60 61 #密文输入 62 #在开头引入库:getpass 63 """ 64 _username = 'JiangQing' 65 _password = '666666' 66 username = input("username:") 67 password = input("password:") 68 #password = getpass.getpass("password:") 69 70 if _username==username and _password==password: 71 print("Welcome user {name} login...".format(name=username)) 72 else: 73 print("Error") 74 print("JixXin") 75 76 #print(username,password) 77 """ 78 79 80 #循环 while / for (for相当于C#里的foreach) 81 count = 0 82 while count<4: 83 count+=1 84 else: 85 print("Error")