python 四种格式化拼接

2021-03-06 02:28

阅读:408

标签:格式   str   inpu   put   python   info   nbsp   form   格式化   

name = input("name:")

age = int(input("age:"))

job = input("job:")

salary = input("salary:")

info = ‘‘‘

-------------info of ‘‘‘+ name +‘‘‘------------

name:‘‘‘+ name +‘‘‘

age:‘‘‘+ str(name) +‘‘‘       

job:‘‘‘+ name +‘‘‘

salary:‘‘‘+ name +‘‘‘

‘‘‘

print(info)

 

info2=‘‘‘

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

name:%s

age:%d

job:%s

salary:%s

‘‘‘%(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)

info4=‘‘‘

-------------info of {0}------------

name:{0}

age:{1}

job:{2}

salary{3}

‘‘‘.format(name,age,job,salary)

print(info4)

python 四种格式化拼接

标签:格式   str   inpu   put   python   info   nbsp   form   格式化   

原文地址:https://www.cnblogs.com/xiaoDK/p/14312794.html


评论


亲,登录后才可以留言!