#取三位小時---format會四舍五入
b = 0.17777
print("{:.3%}".format(b))
#取三位小時---不四舍五入
# 方法一:
a =12.345666
b = str(a)#轉換成字符串
c =b.split('.')#將整數和小數分割
e =c[0] #取列表第一個字符(整數)
f = c[1] #取列表第二個字符(小數)
g = f[0:2] #取第二個字符(小數)的前兩位
h = float(e+'.'+g) #字符串拼接,並轉換成浮點型
# print(type(b))
print(b)
print(c)
print(e)
print(f)
print(g)
print(type(h))
# 方法二:
# def cut(num, c):
# c=10**(-c)
# return (num//c)*c
#
# print (cut(2.998888888,6))
