关于标准化输出
关于标准化输出的形式有3种,官方建议第2种
#Date #Author #Reason name=input('name:') age=input('age:') job=input('job:') salary=input('salary:') #第二种标准化输出 msg2=""" ------------------info of {_name}------------------ name:{_name} age:{_age} job:{_job} salary:{_salary} ------------------info of {_name} end-------------- """.format(_name=name,_age=age,_job=job,_salary=salary) print(msg2) #第三种标准化输出 msg3=""" =====================info3 of {0}========================= name:{0} age:{1} job:{2} salary:{3} =====================info3 of {0} end===================== """.format(name,age,job,salary) print(msg3) #第一种标准化输出 msg1=""" ##############################info1 of %s############################### name:%s age:%s job:%s salary:%s ##############################info1 of %s############################### """%(name,name,age,job,salary,name) print(msg1)
标准化输出与getpass模块的应用
getpass模块在pycharm当中测试会出故障&因而建议在cmd当中调用python进行实行
import getpass _username='nod' _password='90500042' username=input('username:') password=getpass.getpass('password:') if username==_username and password==_password: print('welcome to login:{name}'.format(name=username)) else: print('Your name:{name} or password:{passwd}is disright'.format(name=username,passwd=password))