math=90
chi=89.5
eng=89.99
print("數學是{}分".format(math))
print("數學是{:3.1f}分".format(math)) #{index: 3.1f} <==3是資料總長度,1是取自小數點 1位
print("英語是{:3.1f}分".format(eng))
print("英語是{:^10.3f}".format(eng))
print("{}".format(1/3))
print("{:3.1f}".format(1/3))
"""
b - 二進位制
o - 八進位制
d - 十進位制整數
x - 十六進位制
c - 將整數轉 Unicode
"""
print("17的二進制是{:b}".format(17))
print("17的八進制是{:o}".format(17))
print("17的十進制是{:d}".format(17))
print("17的十六進制是{:x}".format(17))
print("{:c}的unicode碼是97".format(97))
print("{:c}的unicode碼是65".format(65))
結果
數學是90分
數學是90.0分
英語是90.0分
英語是 89.990
0.3333333333333333
0.3
17的二進制是10001
17的八進制是21
17的十進制是17
17的十六進制是11
a的unicode碼是97
A的unicode碼是65
沒有留言:
張貼留言