python - 在函数内添加两个while循环
问题描述
下面是当前代码的摘要,我正在尝试将 weight1 和 weight2 的所有值测试为要在函数内部使用的循环,但是我得到的结果不正确,请各位大神指教,谢谢
weight1 = 0.95
weight2 = 0.05
while weight1 >= 0.05:
weight1 -= 0.05
while weight2 <= 0.95:
weight2 += 0.05
def mod(dates):
df1['score'] = ((df1['EY_rank'] * weight1) + (df1['ROIC_rank'] * weight2)) / 2
print(result)
for i in dates:
mod(i)
解决方案
意图在 Python 中非常重要,因为它是定义语句块的方式。
第一个执行的while循环是
while weight1 >=0.05:
weight1-=0.05
最后,您在下一个 while 循环中使用 weight1=0.05
推荐阅读
- angular - 表单的设置值
- c - C中矩阵和向量乘法的优化
- grails - 是否可以访问 creatCriteria 中的属性值?
- c# - 如何将 URL 中的 ID 传递到下一页
- javascript - 使用 JS 和 PHP 将 textarea 数据发送到文件并保留换行符
- php - 在 Laravel 中与 Repository Pattern 建立雄辩的关系
- javascript - 循环遍历对象数组并创建一个新对象
- wordpress - Wordpress / CMB2 框架 / 在前端显示来自可重复字段的数据
- dbcontext - 使用 .Net Core 2.1 / EF Core 连接两个独立数据库中的表
- c# - 如何配置 Visual Studio 2017 android 模拟器以在 localhost 上工作