python的基本操作格式化输出

#格式化输出
year = input("今年是第几年:")
month = input("现在是几月份:")
day = input("今天是几号")

print("%s年 %s月 %s号" %(year,month,day))
#百分号转义,第二次出现百分号且想打印出%就需要转义
a = 2020
print("这是%d年的%%号" %(a))
#其中name age 和 thing三个变量的位置可以打乱顺序
s1 = "我的名字是{name},今年{age}岁了,我喜欢{thing}".format(age = 10,name = "张三",thing="打篮球")
print(s1)
原文地址:https://www.cnblogs.com/boost/p/13228684.html