我有變數
current_price = 1.158805
但是我需要限制為5個數字(在這種情況下我希望當前價格為1.15880),我該怎么辦?
我需要一個通用的解決方案,因為變數每秒都在變化。
例如,如果我在熊貓資料框中有數字data.close.iloc[-1]怎么辦?
uj5u.com熱心網友回復:
current_price = 1.158805
print(str(current_price)[:-1])
您的輸出將是:
>>> 1.15880
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/354029.html
上一篇:使用回圈計算函式的所有可能值
