标签:python格式化输出
#!/bin/bash/env python #python3.X name = input("name:") age = int(input("age:")) job = input("job:") #格式化1 msg = ‘‘‘ ------info of %s-------- Name:%s Age:%d Job:%s ------------------------ ‘‘‘%(name,name,age,job) print(msg) # 格式化2 msg = ‘‘‘ ------info of {_name}------- Name:{_name} Age:{_age} Job:{_job} ---------------------------- ‘‘‘.format(_name=name, _age=age, _job=job) print(msg) #格式化3 msg = ‘‘‘ --------info of {0}--------- Name:{0} Age:{1} Job:{2} --------------------------- ‘‘‘.format(name,age,job) print(msg)
本文出自 “506554897” 博客,请务必保留此出处http://506554897.blog.51cto.com/2823970/1932879
标签:python格式化输出
原文地址:http://506554897.blog.51cto.com/2823970/1932879