Python 3.x 在python 3.5中,如何将多个列表合并到一个列表中?

Python 3.x 在python 3.5中,如何将多个列表合并到一个列表中?,python-3.x,anaconda,Python 3.x,Anaconda,我正在尝试将多个列表合并到一个列表中 e、 g:['of'、'participants:'、'25']['participants:'、'25'、'we']['25'、'we'、'require'] for wrd in d: child=child.lower() child=child.replace(' ','') dat =child r = re.compile(dat) s=str(wrd) test=[sentence in dat

我正在尝试将多个列表合并到一个列表中

e、 g:
['of'、'participants:'、'25']['participants:'、'25'、'we']['25'、'we'、'require']

for wrd in d:
    child=child.lower()
    child=child.replace(' ','')
    dat =child
    r = re.compile(dat)
    s=str(wrd)
    test=[sentence in dat for sentence in s]
    if r.search(s) and any(test):
        print(s)
代码后:“
['of'、'participants:'、'25']、['participants:'、'25'、'we']、['25'、'we'、'require']


嗯,我也不完全确定你在干什么。使用正则表达式查看代码。也许用字典更好。如果必须使用列表,则可以将其合并到元组中,就像使用循环一样。如果有帮助,请告诉我

>>> list_one = ['of', 'participants:', '25']
>>> list_two = ['participants:', '25', 'we']
>>> list_three = ['25', 'we', 'require']
>>> thing = ()
>>> thing += tuple([list_one])
>>> thing += tuple([list_two])
>>> thing += tuple([list_three])
>>> thing
(['of', 'participants:', '25'], ['participants:', '25', 'we'], ['25', 'we', 'require'])
>>> for i in range(len(thing)):
...     print thing[i]
... 
['of', 'participants:', '25']
['participants:', '25', 'we']
['25', 'we', 'require']

嗯,我也不完全确定你在干什么。使用正则表达式查看代码。也许用字典更好。如果必须使用列表,则可以将其合并到元组中,就像使用循环一样。如果有帮助,请告诉我

>>> list_one = ['of', 'participants:', '25']
>>> list_two = ['participants:', '25', 'we']
>>> list_three = ['25', 'we', 'require']
>>> thing = ()
>>> thing += tuple([list_one])
>>> thing += tuple([list_two])
>>> thing += tuple([list_three])
>>> thing
(['of', 'participants:', '25'], ['participants:', '25', 'we'], ['25', 'we', 'require'])
>>> for i in range(len(thing)):
...     print thing[i]
... 
['of', 'participants:', '25']
['participants:', '25', 'we']
['25', 'we', 'require']

s=str(wrd)测试=[数据中的句子用于s中的句子]如果r.search(s)和any(测试):打印。。。。我得到的是['of'、'participants:'、'25']['participants:'、'25'、'we']['25'、'we'、'require']但是我需要输出为['of'、'participants:'、'25'、'we']、['25'、'we'、'require']让我知道这是否有助于我认为这就是你的提问列表中的内容['25','we','require']这就是我如何得到的gettings=str(wrd)test=[s中句子的dat]如果r.search(s)和any(test):print(s)…我得到的是['of','participants:','25']['participants:','25','we']['25','we','require'],但我需要输出为['of','participants:','25','we']让我知道这是否有帮助,我想这就是你的问题清单之一,参与者: