所以我有一个从一个人那里获得多个参数的函数:
@bot.command(name='koth')
async def koth_announcer(*args):
但是我怎么能在某个点将参数拆分成字符串呢?例如:用户将输入:The Goblin Camp | -39,19 | 12:00 | 28/12
我需要能够将字符串拆分为|
。我试过了:
args = str(args).split('|')
但是这仍然会将所有内容都分开。像这样:
["('The'", " 'Goblin'", " 'Camp'", " '|'", " '-39", "19'", " '|'", " '12:00'", " '|'", " '28/12')"]
答案 0 :(得分:2)
您可以这样做:首先加入列表然后拆分
@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 |