[英]Change parameter value with iteration
I have an Excel file, and I need to grab some data from it. 我有一个Excel文件,我需要从中获取一些数据。 When I use regular integers, everything works just fine, but now I got very stuck - how can I change row value? 当我使用正整数时,一切都很好,但是现在我很困-如何更改行值? That's what I have for now 那就是我现在所拥有的
dict_keys = ['Id', 'First name', 'Age', 'Condition Name', 'BiRad', 'Relevant Modality']
dict_values = [p_id, person_name, p_age, name, br, r]
if f == 'Mass':
#concatvals accepts (row, col, width, start, stop)
shape = concatvals(row, 14, 5, 14, 19) #if row = 0
margin = concatvals(row, 14, 5, 14, 19) #here row should be 1
density = concatvals(row, 14, 5, 14, 19) # and here 2 - how to achieve that?
dict_keys += ['Relevant Finding','Shape', 'Margin', 'Density']
dict_values += [f, shape, margin, density]
And that's what I tried: 这就是我尝试过的:
if f == 'Mass':
params = [shape, margin, density]
loc = (row, 14, 5, 14, 19)
for param in params:
params[i] = concatvals(loc)
loc[0] +=1
But didn't succeed to go further. 但是没有成功。 Any suggestions? 有什么建议么? Thanks! 谢谢!
Make row
a loop parameter, and save the calculated values in an array: 将row
设为循环参数,并将计算出的值保存在数组中:
dict_keys = ['Id', 'First name', 'Age', 'Condition Name', 'BiRad', 'Relevant Modality']
dict_values = [p_id, person_name, p_age, name, br, r]
#concatvals accepts (row, col, width, start, stop)
vals = []
for row in range(3):
vals += concatvals(row, 14, 5, 14, 19)
dict_keys += ['Relevant Finding','Shape', 'Margin', 'Density']
dict_values += [f]
dict_values += vals
Its a bit confusion you use dict__
for things which are not a dict, but a list... If I understand what you want I would arrive at this: 您将dict__
用于不是dict而是列表的内容有点困惑。如果我理解您想要的内容,我会得出以下结论:
params = {'Mass': ['shape', 'margin', 'density'],
'Next': ['some', 'other', 'list']}
if f == 'Mass':
loc = (row, 14, 5, 14, 19)
result = [f]
for param in params[f]:
result.append(concatvals(loc))
loc[0] +=1
dict_keys += ['Relevant Finding','Shape', 'Margin', 'Density']
dict_values += result
elif f == 'Next':
... etc ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.