python如何从两个数组里取数据再存到另一个数组里 10
例如:数组内嵌套数组[{"ip","sh","li"},{"qw","ty","ko"}]如何把这个数组里的"ip"和"qw"存到另一个嵌套数组c里面...
例如:数组内嵌套数组[{"ip","sh","li"},{"qw","ty","ko"}]
如何把这个数组里的"ip"和"qw"存到另一个嵌套数组c里面 展开
如何把这个数组里的"ip"和"qw"存到另一个嵌套数组c里面 展开
1个回答
展开全部
dt=[{"ip","sh","li"},{"qw","ty","ko"}]
c.extend([i for i in dt if 'ip' in i or 'qw' in i])
Python 3.5.2 (default, Dec 7 2016, 23:38:49)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> dt=[{"ip","sh","li"},{"qw","ty","ko"}]
>>> c=[]
>>> c.extend([i for i in dt if 'ip' in i or 'qw' in i])
>>> c
[{'li', 'sh', 'ip'}, {'ko', 'qw', 'ty'}]
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询