python将整数均分成N等分,,在python中,需
python将整数均分成N等分,,在python中,需
在python中,需要将整数均分成N等分。python divide integers N equal parts sum
# 拆分整数def split_integer(m, n): assert n > 0 quotient = int(m / n) remainder = m % n if remainder > 0: return [quotient] * (n - remainder) + [quotient + 1] * remainder if remainder < 0: return [quotient - 1] * -remainder + [quotient] * (n + remainder) return [quotient] * n
x = split_integer(98, 8)print(x)[12, 12, 12, 12, 12, 12, 13, 13]
python将整数均分成N等分
相关内容
- Mac下编译Thrift的时候Python2.7会报错 site-packages':
- python vs java的rsa加密,,首先:java的加密
- HTMLTestRunner_PY3.py支持 python3.x github python3版本,,github源
- python数据分析与展示(一),,NumPy库学习一.
- Python os.walk() 遍历出当前目录下的文件夹和文件,,os.
- 【python】Numpy中stack(),hstack(),vstack()函数详解,,转自
- 使用vim编辑python,,1.vim使用1.v
- python IDE —— 在IntelliJ IDEA中导入pipenv管理的项目,,?尝
- Pycharm报错解决:error:please select a valid Python interpreter,
- Python+selenium之跳过测试和预期失败,,在运行测试时,需
评论关闭