0
您能否幫助我修改此代碼以將數字寫入到cvs文件中的2個小數位?在cvs文件中將字符串寫入2個小數位
outfile = open("numbers.csv", "a")
outfile.write(str(datetime.strftime(datetime.now(), '%Y-%m-%d %H:%M:%S')) + "," + str(number_1) + "," + str(number_2) + "," + str(number_3)+ "," + str(number_4) + "," + str(number_5) + "," + str(number_6) + "," + str(number_7) + "," + str(number_8) + "," + str(number_9) +"\n")
非常感謝。
你的意思是['round()'](https://docs.python.org/3/library/functions.html#round)? – TigerhawkT3
我還建議用一個基本的'list'替換所有'number_1','number_2'等。 – TigerhawkT3