首页 > 解决方案 > 从 Decimal('6') 中提取 int

问题描述

我做了一个 SQL Select,它会返回一些东西,包括一个数字。但它看起来像这样:

Decimal('6')

如何从该字段中检索数字 6?
我还将添加此 Decimal 对象的屏幕截图,以帮助您了解我在看什么。

十进制对象

提前致谢!

标签: python

解决方案


You can pass it to int.

>>> from decimal import Decimal
>>> Decimal('6')
Decimal('6')
>>> int(Decimal('6'))
6

推荐阅读