37,721
社区成员
发帖
与我相关
我的任务
分享
1.xr = [['a',1], ['a', 2], ['b', 3], ['b',4],['c',5]]
2.xr = [['a',1], ['b', 2], ['c', 3], ['d',4],['e',5]]
3.xr = [['a',1], ['a',2], ['b', 3], ['c',4], ['c',5']]
4.xr = [['a', 1]]
def func(data):
temp = []
res1 = []
res2 = []
for item in data:
if item[0] in temp:
res2.append(item[1])
else:
res1.append(item[1])
temp.append(item[0])
return (res1, res2)
def main():
xr = [['a',1], ['a', 2], ['b', 3], ['b',4],['c',5]]
print(func(xr))
def GetNum():
global g_InactiveNumber
global g_ActiveNumber
g_InactiveNumber = []
if(xr[0] == xr[-1]):
g_ActiveNumber.append(xr[0][1])
return
lastNum = 0
lastModuleID = 0
for tmpList in xr:
if(lastModuleID == 0):
lastModuleID = tmpList[0]
lastNum = tmpList[1]
elif(lastModuleID == tmpList[0]):
if(lastSlotNum not in g_ActiveNumber):
g_ActiveNumber.append(lastNum)
if(tmpList[1] not in g_InactiveNumber):
g_InactiveNumber.append(tmpList[1])
elif(lastModuleID != tmpList[0]):
if(lastSlotNum not in g_InactiveNumber or lastNum not in g_ActiveNumber):
g_ActiveNumber.append(lastSlotNum)
g_ActiveNumber.append(tmpList[1])
else:
g_ActiveNumber.append(tmpList[1])
lastModuleID = tmpList[0]
lastNum = tmpList[1]
xr = [['a',1], ['a', 2], ['b', 3], ['b',4],['c',5]]
# xr=[['a',1], ['b', 2], ['c', 3], ['d',4],['e',5]]
# xr=[['a',1], ['a',2], ['b', 3], ['c',4], ['c',5']]
# xr=[['a', 1]]
res1 = []
res2 = []
temp = []
for item in xr:
if item[0] in temp:
res2.append(item[1])
else:
res1.append(item[1])
temp.append(item[0])