对于此代码:
for crop in database:
print("The current crop is :", crop)
x.all_crop_parameters_match_the_PRA_ones = True
while x.all_crop_parameters_match_the_PRA_ones :
ASSESS_Tmin( crop, x, PRA)
print("x.all_crop_parameters_match_the_PRA_ones = ", x.all_crop_parameters_match_the_PRA_ones)
ASSESS_Water( crop, PRA, x)
print("x.all_crop_parameters_match_the_PRA_ones = ", x.all_crop_parameters_match_the_PRA_ones)
ASSESS_pH(crop, PRA, x)
我得到以下结果:
The current crop is : FBRflx
Checking minimum Temperatures...
x.all_crop_parameters_match_the_PRA_ones = False
Checking the Water Resources...
Verifying if the Water Resources match with the Tmin supported by the crop...
x.all_crop_parameters_match_the_PRA_ones = False
The soil pH of this PRA matches to the crop requirements.
This crop is edible for the current PRA !
我不明白为什么程序看到x.all\u crop\u parameters\u match\u the \u PRA\u one是假的,并且仍然运行下一个函数,而不是中断循环并切换到下一个裁剪。你知道吗
x是一个包含我使用的所有变量的类,修改的是代码中的几个函数。这可能是一个错误,因为布尔值来自一个类吗?你知道吗
你贴出来的样子和我期望的一样。while循环只有在执行其中的所有代码时才会重新评估条件。。。你知道吗
如果希望while代码在中间中断,请尝试设置中断:
请注意,它将在时间
x.all_crop_parameters_match_the_PRA_ones == True
的循环中。如果只想在while
内执行一次代码,而不是在循环中执行,可以尝试:相关问题 更多 >
编程相关推荐