使用join()的python合并列表

使用join()的python合并列表,python,Python,我有以下清单: lst = [['a','!b'], ['91','q'], ['!t','3','p']] 我希望以下内容作为输出: test = a and !b or 91 and q or !t and 3 and p 子列表中的单个文本被制成单个文本,并使用“和”连接,然后子列表使用“或”连接在一起 我尝试了以下方法,有人可以更正我的代码吗 def output(self): temp = ['and'.join(sublist[i]) for i in subl

我有以下清单:

lst = [['a','!b'], ['91','q'], ['!t','3','p']]
我希望以下内容作为输出:

test = a and !b or 91 and q or !t and 3 and p
子列表中的单个文本被制成单个文本,并使用“和”连接,然后子列表使用“或”连接在一起

我尝试了以下方法,有人可以更正我的代码吗

   def output(self):
      temp = ['and'.join(sublist[i]) for i in sublist]
      test = ['or'.join(sublist) for sublist in self.lst]
      return self.test
一下子:

def output(lst):
    return " or ".join(" and ".join(s) for s in lst)
一下子:

def output(lst):
    return " or ".join(" and ".join(s) for s in lst)