我有以下列表
p=[list(['a', 'b', 'c']), list(['d', 'e'])]
我想制作每个元素的子集(大小为2)并列出它们,这将给出如下输出:
[[('a', 'b'), ('a', 'c'), ('b', 'c')],[('d', 'e')]]
为此,我编写了以下函数,
def x(m,n):
for i in x:
z=list(itertools.combinations(i, n))
return(z)
当我申请z(m,2)
时,我只得到最后一个元素:
[('d', 'e')]
我想知道我做错了什么吗?
答案 0 :(得分:1)
这是因为您每次都设置z而不是附加z:
{
"targets": [{
"target_name": "js-inv-mpu6050",
"cflags!": [ "-fno-exceptions" ],
"cflags_cc!": [ "-fno-exceptions" ],
"sources": [
"src/main.cpp",
"src/test.c"
],
'include_dirs': [
"<!@(node -p \"require('node-addon-api').include\")"
],
'libraries': [],
'dependencies': [
"<!(node -p \"require('node-addon-api').gyp\")"
],
'defines': [ 'NAPI_DISABLE_CPP_EXCEPTIONS' ]
}]
}
收益:
undefined symbol: _Z6addExtii