如果要查找某项运动,我正在计算数据,则应为各组名称和各自的权重计算数据,如果找不到,则应附加'0'...
这是我的代码:
Compare-Object
获得的输出是:
Private Sub lvRegistered_SelectedIndexChanged(sender As Object, e As
EventArgs) Handles lvRegisteredV1.SelectedIndexChanged
If lvRegisteredV1.SelectedItems.Count > 0 Then
pbRear.Image = Image.FromFile(lvRegisteredV1.SelectedItems(0).ToString)
End If
End Sub
------i have tried this but shows an error "An unhandled exception
of type 'System.NotSupportedException' occurred in mscorlib.dll
Additional information: The given path's format is not supported."
尽管Name_list中只有9个名称,但这里添加了更多的零。...
所需的输出是:
Name_list = ['akshay', 'swapnil', 'parth','juhi','megha', 'varun', 'tarun','gaurav', 'geeta']
dic1 = {
'g1': ['akshay', 'swapnil', 'parth','juhi'],
'g2': ['megha', 'varun', 'tarun'],
'g3': ['gaurav', 'geeta']
}
dic2 = {
'g1': ['hockey', 'basketball', 'football'],
'g2': ['cricket', 'chess', 'badminton', 'carrom'],
'g3': ['pool', 'hockey', 'tabletennis']
}
dic3 = {
'g1': ['45', '35', '56'],
'g2': ['67', '76', '65', '50'],
'g3': ['8', '70', '96']
}
for k,v in dic2.items():
for i,l in enumerate(v):
if l=='hockey':
comp_list = dic1[k]
weight = dic3[k][i]
for name in Name_list:
if name in comp_list:
a = (1*int(weight))/100
else:
a = 0
print(a)
有人可以帮助我解决这个问题吗?
答案 0 :(得分:0)
您遍历dic 3的所有元素及其数组中的所有后续元素。您有两次“曲棍球”字段,这意味着您将执行两次出现在Name_list中的循环,因此将打印2x9 = 18次。