如題,程序第4行開始,for循環(huán)接if判斷,之后的name=self._nic_ovs_name_pattern.search(o) 指的是if條件判斷返回true才執(zhí)行賦值操作嗎?還是if返回False執(zhí)行的呢?最后一行的return ovs_nics,是什么條件滿足后返回的呢?這個函數(shù)的整體執(zhí)行順序看的不是太明白,還請指教,謝謝.def __extract_ovs_nic_detail(self, output): ovs_nics = [] ovs_nic = {} for o in output.split('\n'): if '_uuid : ' in o: ovs_nic = {} name = self._nic_ovs_name_pattern.search(o) if not name is None: ovs_nic['name'] = name.group(2).strip('\"') mac = self._nic_ovs_mac_pattern.search(o) if not mac is None: ovs_nic['mac'] = mac.group(2).strip('\"') mtu = self._nic_ovs_mtu_pattern.search(o) if not mtu is None: ovs_nic['mtu'] = mtu.group(2) speed = self._nic_ovs_speed_pattern.search(o) if not speed is None: ovs_nic['speed'] = str(int(speed.group(2)) / 1000000) + 'Mb/s' if 'type : ' in o: ovs_nics.append(ovs_nic) return ovs_nics
python下for循環(huán)接if判斷的函數(shù)執(zhí)行順序
qq_花開花謝_0
2018-07-04 14:29:23