如何在Python3中获取/拆分多个字符串输入

如何在Python3中获取/拆分多个字符串输入,python,python-3.x,Python,Python 3.x,我有一个函数,它从一个人那里获取多个参数: @bot.command(name='koth') async def koth_announcer(*args): 但是我如何才能在某一点将参数拆分为字符串呢?例如:用户将输入以下内容:地精营地|-39,19 | 12:00 | 28/12 我需要能够在|处拆分字符串。我试过: args = str(args).split('|') 但这仍然会将所有内容作为单独的返回。像这样: ["('The'", " 'Goblin'", " 'Camp'",

我有一个函数,它从一个人那里获取多个参数:

@bot.command(name='koth')
async def koth_announcer(*args):
但是我如何才能在某一点将参数拆分为字符串呢?例如:用户将输入以下内容:
地精营地|-39,19 | 12:00 | 28/12

我需要能够在
|
处拆分字符串。我试过:

args = str(args).split('|')
但这仍然会将所有内容作为单独的返回。像这样:

["('The'", " 'Goblin'", " 'Camp'", " '|'", " '-39", "19'", " '|'", " '12:00'", " '|'", " '28/12')"]

您可以这样做:首先加入列表,然后拆分它

@bot.command(name='koth')
async def koth_announcer(*args):
    msg = "".join(args) #joins the list of words first
    content = msg.split('|') #split the words at |

您可以这样做:首先加入列表,然后拆分它

@bot.command(name='koth')
async def koth_announcer(*args):
    msg = "".join(args) #joins the list of words first
    content = msg.split('|') #split the words at |

…但是你的预期输出是什么呢?我需要类似于
[“('TheGoblinCamp','-39,19')”]
…但是你的预期输出是什么呢?我需要类似于
[“('TheGoblinCamp','-39,19')”]
的东西。你也可以把它写成
content=“”.join(args)。split('-39,19'))
Argh,非常感谢你
['TheGoblinCamp','-39,19','12:00','28/12']
您也可以将其写成
content=“”.join(args).split('|')
Argh非常感谢您<代码>[《地精营地》,'-39,19',12:00',28/12']