2024-10-01 19:26:36 发布
网友
我试着在一个特定的字符上拆分一个列表。我的代码我试过了:
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
所以它会在“&;“南非”
我猜这就是你的意思:
for x in lol: print x.split("&sa")[0]
它输出:
我猜这就是你的意思:
它输出:
相关问题 更多 >
编程相关推荐