输入列表:(仅当索引[1]具有/)
时ListView
退货清单:
['A', 'dog,big/small;rat,big/small', '12', '21']
答案 0 :(得分:0)
这个适用于该类型的一般输入字符串:
def permute(s):
a, b = s.split(',')
return [a + "," + c for c in b.split('/')]
def traverse(s):
parts = s.split(';', 1)
if len(parts) == 1:
return permute(s)
else:
return sum([[k + ';' + l for l in traverse(parts[1])] for k in permute(parts[0])], [])
for s in traverse('dog,big/small;rat,big/small'):
print ['A', s, '12', '21']