So I have a function which obtains multiple arguments from a person:
@bot.command(name='koth')
async def koth_announcer(*args):
But how am I able to split the arguments into strings at a certain point? For instance: The user will input this: The Goblin Camp | -39,19 | 12:00 | 28/12
The Goblin Camp | -39,19 | 12:00 | 28/12
I need to be able to split the string at |
. I tried:
args = str(args).split('|')
But this still returns everything as separate. Like this:
["('The'", " 'Goblin'", " 'Camp'", " '|'", " '-39", "19'", " '|'", " '12:00'", " '|'", " '28/12')"]
You can do it like so: first join the list then split it
@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 |
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.