Python的学习之旅———格式化输出

时间:2017-09-06 23:32:30   收藏:0   阅读:379
占位符 %s 和%d .%d只能是整数
# 练习:用户输入姓名、年龄、工作、爱好 ,然后打印成以下格式
# ------------ info of Egon -----------
# Name : Egon
# Age : 22
# Sex : male
# Job : Teacher
# ------------- end -----------------

name=input(‘请输入你么名字:‘)
age=int(input(‘请输入你的年龄:‘))
sex=input(‘请输入你的性别:‘)
jobe=input(‘请输入你的工作:‘)
print(‘------------ info of Egon -----------\nName :%s\nAge :%d\nSex :%s\nJob :%s\n------------- end -----------------‘
%(name,age,sex,jobe))

原文:http://www.cnblogs.com/surehunter/p/7487340.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!