1. 程式人生 > >python變量及用戶交互,用戶名格式化輸出

python變量及用戶交互,用戶名格式化輸出

格式化輸出 input 格式 格式化 word 變量 password info user

變量

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變量及用戶交互,用戶名格式化輸出