安全问答

安全问答是一个知识全球问答,包含丰富的问答知识

首页 常规 游戏 娱乐 科技 程序员

Python 函数:将十进制整数转换为任意进制数(非递归)

  • 日期: 2027-06-27
  • 标签: 常规

def decimal_to_base(n, base): if base < 2 or base > 36: return 'Invalid base' digits = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' result = '' while n > 0: digit = n % base result = digits[digit] + result n //= base return result if result else '0'

Python 函数:将十进制整数转换为任意进制数(非递归)

原文地址: https://www.cveoy.top/t/topic/ohO3 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录

  • 上一篇: Spring Boot @RestController 和 @RequestMapping 注解详解:社团成员管理示例
  • 下一篇: 用KNN算法作为基分类器的AdaBoost算法实现和Python代码

© 2019 • 2025 - 安全问答 站长邮箱:wxgpt@qq.com    ICP备案/许可证号:豫ICP备2024104334号-2