如何在获取数据时保留mysql格式

2024-04-25 22:08:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我将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

Tags: fromexecutetable数字customerthisselectwill