一、輸出
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%