Python:排序一组字符串

2024-05-16 00:30:02 发布

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

我有一个列表:[ "123-12 abc, qwerty", "pol, T. top", "14-89 toy, rap"]。你知道吗

我想用正则表达式这样输出它:

qwerty abc第123-12页

T.顶部pol

说唱玩具14-89

有什么办法可以解决这个问题吗?非常感谢。你知道吗


Tags: 列表topabc玩具toyqwerty办法pol
1条回答
网友
1楼 · 发布于 2024-05-16 00:30:02

没有必要使用常规的表情。这里这是一个简单的解决方案

l = [ "123-12 abc, qwerty", "pol, T. top", "14-89 toy, rap"]
for i in l:
    t = i.split(",")
    print(t[1],t[0])

相关问题 更多 >