Python拆分列表

2024-10-01 19:26:36 发布

您现在位置:Python中文网/ 问答频道 /正文

我试着在一个特定的字符上拆分一个列表。我的代码我试过了:

lol = ['lol&sa=asddaa', 'test&sa=asd', 'well&sa=123123']
test = "\n".join(lol)

for x in test:
    print test.split("&sa")[0]

但这不管用。我只是得到“lol”像一百倍的输出。解决办法是什么

我想要的输出:

lol
test
well

所以它会在“&;“南非”


Tags: 代码intest列表forsa字符split

热门问题