标签:mat inpu orm 三种方式 file 占位符 格式 div 输入
# -*- coding:utf-8 -*- """ @Author:janson @Date:2018/8/1 @File:StrFormat.py """ #实现字符串的格式化:三种方式(字符串拼接、%s%d%f占位符、format()) # python2.x 用raw_input() python3.x直接用input() 忘记python2.x里的input用法 name = raw_input(‘请输入姓名:‘) #age = raw_input(‘年龄:‘) age = int(raw_input(‘年龄:‘)) job = raw_input(‘工作:‘) salary = int(raw_input(‘薪水:‘)) info1 = ‘‘‘ ------------info of ‘‘‘+ name +‘‘‘---------------- Name: ‘‘‘+ name + ‘‘‘ Age:‘‘‘+ age + ‘‘‘ Job:‘‘‘+ job + ‘‘‘ Salary:‘‘‘+ salary + ‘‘‘ ‘‘‘ print info1 info2=‘‘‘‘ ------------info of %s---------------- Name:%s Age:%d Job:%s Salary:%d ‘‘‘%(name,name,age,job,salary) print info2 info3=‘‘‘ ------------info of {_name}---------------- Name:{_name} Age:{_age} Job:{_job} Salary:{_salary} ‘‘‘.format(_name=name,_age=age,_job=job,_salary=salary) print info3
标签:mat inpu orm 三种方式 file 占位符 格式 div 输入
原文地址:https://www.cnblogs.com/janson071/p/10371218.html