海绵宝宝撒
def get_result(x): len_x = len(x) res = [] for i in range(0, 2**(len_x)): res.append(take(x, i)) print("count:{}".format(len(res))) return resdef take(x, i): res = set() idx = 1 while i: if i & 1: res.add(idx) idx += 1 i >>= 1 return resprint(get_result({1, 2, 3}))print(get_result({1, 2, 3, 4}))您是否正在寻找像上面这样的简单解决方案?