creepyzzzzzyq
creepyzzzzzyq
2019-04-10 19:53

求问各位大佬怎么用python获取排序后二维列表在原列表中的下标,我的代码是这样的,但是报错了

  • python
  • list

g = [0] * len(machine)
for i in machine:
g[i] = [0] * len(time_slot)

for i in machine:
g[i] = c[i]

print(g)

for i in machine:
c[i].sort()

print(c)

cost_index = [0] * len(machine)
for i in machine:
cost_index = [0] * len(time_slot)

for i in machine:
for k in time_slot:
cost_index[i][k] = g[i].index(c[i][k])

print(cost_index)

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答