if net.res_bus.vm_pu[self.bus] > 1.005 :
self.p_mw = self.p_mw + self.data_source.get_time_step_value(time_step=time,profile_name=self.p_profile)
self.soc_percent += ((self.data_source.get_time_step_value(time_step=time,profile_name=self.p_profile)*15/60)/self.max_e_mwh) * 100我正在使用Python中的pandapower包。在这里,我需要检查一个条件,如果它为真,我需要执行一些计算,在做完计算后,我需要再次检查它,这应该会一直持续到它为真。因此,在计算之后,我需要再次转到if条件。我该怎么做呢?我试过for循环,它在某个地方搞乱了。
发布于 2020-02-14 03:27:29
您正在寻找一个python while loop.
您可以像这样构造代码,用while替换if
while net.res_bus.vm_pu[self.bus] > 1.005 :
self.p_mw = self.p_mw + self.data_source.get_time_step_value(time_step=time,profile_name=self.p_profile)
self.soc_percent += ((self.data_source.get_time_step_value(time_step=time,profile_name=self.p_profile)*15/60)/self.max_e_mwh) * 100如果不能更好地理解您的代码,我看不到net.res_bus.vm_pu[self.bus]的值发生了变化。如果是这种情况,您可能需要检查while中的其他变量
https://stackoverflow.com/questions/60214980
复制相似问题