python中的交互
1 # author:zfp 2 3 name=input("name:") 4 age=int(input("age:"))#强制转换为integer 5 job=input("job:") 6 salary=input("salary:") 7 8 info=''' 9 ----------info of %s ------------- 10 Name:%s 11 Age:%d 12 Job:%s 13 Salary:%s 14 ''' %(name,name,age,job,salary) 15 16 info2=''' 17 ----------info of {_name} ---------- 18 Name:{_name} 19 Age:{_age} 20 Job:{_job} 21 Salary:{_salary} 22 '''.format(_name=name, 23 _age=age, 24 _job=job, 25 _salary=salary) 26 27 info3=''' 28 ----------info of {0} --------------- 29 Name:{0} 30 Age:{1} 31 Job:{2} 32 Salary:{3} 33 '''.format(name,age,job,salary) 34 35 print(info3)
这是交互的几种方法。