python - 如何在python中将数字转换为整数
问题描述
我想知道如何在python 中1,999,999
落地1,000,000
或落地?我用过,但它只是为了删除小数部分。2,000,108
2,000,000
math.floor()
解决方案
这样做:
math.floor(num / 1000000) * 1000000
例如:
>>> num=1999999
>>> math.floor(num / 1000000) * 1000000
1000000.0
>>> num=2000108
>>> math.floor(num / 1000000) * 1000000
2000000.0
推荐阅读
- rust - Why does RefCell:borrow_mut result in a BorrowMutError when used on both sides of a short-circuiting boolean AND (&&)?
- java - 将字符串中的“[”和“]”替换为“,”错误不能这样做
- r - 在全局环境中定义默认缓存德雷克
- file - 在 Bitrise Workflow 中下载公共文件
- r - 在 R 中验证数据框中的重复项
- python - 简单的卷积神经网络
- spring - 使用 .retrieve() 或 .exchange() 时 Spring WebFlux 会自动关闭连接吗?
- shell - Expect 没有检测到字符串
- php - Laravel 8 运行 composer require laravel/passport 时,您的需求无法解析为一组可安装的软件包
- node.js - 在 macOS Catalina 上运行的 NestJS 项目上的 NodeJS 14 崩溃