受Python tips: Map, Filter Reduce的启发,我发表了以下声明:
globalTags = ['deviceName'\
, 'processIndex'\
, 'timingGroupID'\
, 'sequenceIndex'\
, 'chainIndex'\
, 'eventNumber'\
, 'chainStartStamp'\
, 'acqStatus'\
, 'sequenceStartStamp']
chargeTags = ['charge_status', 'charge_units']
chargeTags = list(map(lambda tag: chargeTags.append(tag), globalTags))
这将产生<class 'list'>: [None, None, None, None, None, None, None, None, None]
而不是包含两个初始列表的值的预期联接列表。我做错了什么,什么会是更好的陈述?
答案 0 :(得分:2)
您可以使用+
运算符来连接数组。
globalTags = [
'deviceName',
'processIndex',
'timingGroupID',
'sequenceIndex',
'chainIndex',
'eventNumber',
'chainStartStamp',
'acqStatus',
'sequenceStartStamp'
]
chargeTags = ['charge_status', 'charge_units']
chargeTags = chargeTags + globalTags