我正在使用.get_seconds()
函數減去時間並將datetime轉換爲字符串。移動十進制而不捨入
diff = end_date - start_date
seconds = diff.total_seconds()
months = seconds/2628000
years = months/12
當我打印years
,數量就出來0.830136986301
我在Python
format(years, '.0f')
看格式化選項,但這個輪次高達1
。無論如何,我可以在沒有四捨五入的情況下將「十進制」減掉?
是'Math.floor()'你想要什麼? – Barmar
是的!這就是我一直在尋找的:-)謝謝。 –