I have the following code and I am trying to iterate across values during a search and then append to the values.
for delvt, pin in zip(temp_delvt_list, temp_pin_list):
temp[delvt].append(pin)
print temp
SPFFile = open(pathSPFfiles + temp_cell + ".spf", "r")
for line in SPFFile:
for pin in temp[delvt]:
print pin
Output of temp is:
defaultdict(<type 'list'>, {'0.1995': ['in1', 'in2'], '0.399': ['in0', 'y']})
Output of pin is only:
in0
iny
Why is pin not outputting in1 and in2 also?
因为您在更改delvt
的循环delvt
,因此您只使用最后指定的值。
您可以使用dict_var.values()
来迭代dict_var
值
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.