python - 从 Decimal('6') 中提取 int
问题描述
我做了一个 SQL Select,它会返回一些东西,包括一个数字。但它看起来像这样:
Decimal('6')
如何从该字段中检索数字 6?
我还将添加此 Decimal 对象的屏幕截图,以帮助您了解我在看什么。
提前致谢!
解决方案
You can pass it to int
.
>>> from decimal import Decimal
>>> Decimal('6')
Decimal('6')
>>> int(Decimal('6'))
6
推荐阅读
- wagtail - 从父页面调用数据
- .net - .net web.config 如何使用
以请求标头作为输入? - python - 使用 CrawlerProcess 顺序运行两个蜘蛛时出现 ReactorNotRestartable 错误
- javascript - xhttp 不返回 anythink javascript
- xamarin - Xamarin Forms iOS 切换渲染器空引用异常
- linux - 如何编辑多个文件中的字符串[bash]?
- python - 在 keras custom_objects 中加载预训练的注意力模型
- python-3.x - “列表”对象没有属性“形状”
- azure - Azure 通知中心设备安装并发送测试消息成功,但没有消息发送到应用程序
- android - 在HUAWEI P40上测试DRM示例代码提示“Failed to open session”