2024-04-25 22:08:09 发布
网友
我将customer_price存储为DECIMAL (8,2)。你知道吗
customer_price
DECIMAL (8,2)
使用Python,如何保留小数点后的两个数字?你知道吗
cursor.execute("SELECT customer_price FROM table") customer_price = cursor.fetchone() # this will give me values such as 7 instead of 7.00
这并不意味着Python会丢失小数点后的数字。如果你只需要用两个小数位打印出来,那么你应该看看this question的答案。即:
'%.2f' % your_number
这并不意味着Python会丢失小数点后的数字。如果你只需要用两个小数位打印出来,那么你应该看看this question的答案。即:
相关问题 更多 >
编程相关推荐