round()函數(shù)計算四舍五入后有時也沒有按照要求的位數(shù)保存啊
a=3.14?
b=1.57
s=a*b
print(s)? ? ? ? ? ? ? ? ? ? ? ? ? ???#? ==>4.9298
print(round(s,0))? ? ? ? ? ? ?#? ==>5.0
print(round(s,1))? ? ? ? ? ? ?#? ==>4.9
print(round(s,2))? ? ? ? ? ? ?#? ==>4.93
print(round(s,3))? ? ? ? ? ? ?#? ==>4.93
print(round(s,4))? ? ? ? ? ? ?#? ==>4.9298
print(round(s,5))? ? ? ? ? ? ?#? ==>4.9298
print(round(3.2,0))? ? ? ? ? ? ?#? ==>3.0
print(round(3.2,1))? ? ? ? ? ? ?#? ==>3.2
2023-02-15
因為s的計算結果是 4.9298,他只有4位小數(shù)
2022-11-29
a=3.14?
b=1.57
s=a*b? ? ? ? ? ? ? ? ? ?
print(round(s,5))? ? ? ? ? ? ?#? ==>4.9298
你是說這個? 你要求保留五位數(shù),但結果沒有保留五位數(shù)?
s的計算結果是 4.9298啊.? ?手動捂臉??