dic and set

时间:2021-12-18 19:31:44

一、输出

print('Hello, World!')

二、格式化输出

1、占位符:%

2、表示

1)%s,代表string

2)%d,代表dight

3)%f,代表float

name = input("请输入姓名:")
age = int(input("请输入年龄:"))
info = """---------info %s-----------
姓名: %s
年龄: %d
------------end-------------
"""
print(info % (name, name, age))
"""
结果:
请输入姓名:tom
请输入年龄:24
---------info tom-----------
姓名: tom
年龄: 24
------------end-------------
"""

4)%%,转义

print('中奖率:%d%%' % 5)   # 中奖率:5%