首页 > 代码库 > python变量及用户交互,用户名格式化输出

python变量及用户交互,用户名格式化输出

变量

name = wwjun

Name2 = “wwjun”

print (“name,Name2”)

 

用户交互

Username = input (“username:”)

Password = input (“password:”)

Print(username,password)

 

用户名格式化输出

name = input (“name:”)

age = input (”age:”)

job = input (“job:”)

salary = input (“salary:”)

Info = ’’’

----------- info of %s ----------

Name:%s

Age:%s

Job:%s

Salary:%s

’’’ % (name,name,age,job,salary) –

 

第二种

Info2 = ’’’

------------- info of {_name} -----------

Name:{_name}

Age:{_age}

Job:{_job}

Salary:{_salary}

’’’ .format(_name=name,

         _age=age,

         _job=job,

         _Salary=salary)

Print(info2)

python变量及用户交互,用户名格式化输出