Python 如何连接函数的参数以形成字符串?

Python 如何连接函数的参数以形成字符串?,python,Python,我试图从changegame函数的属性中获取一个字符串,以便更改我正在开发的机器人的状态 async def changegame(*game_chosen: str): """Changes the game the bot is playing""" game_str = discord.Game(name=game_chosen) try: await bot.change_status(game=game_str, idle=False)

我试图从
changegame
函数的属性中获取一个字符串,以便更改我正在开发的机器人的状态

async def changegame(*game_chosen: str):
    """Changes the game the bot is playing"""
    game_str = discord.Game(name=game_chosen)
    try:
        await bot.change_status(game=game_str, idle=False)
        await bot.say("```Game correctly changed to {0}```".format(game_chosen))
这不会导致识别字符串,但会导致:


游戏已正确更改为('Test'、'string'、'123')
要解决最初的问题,请尝试一个简单的连接:

' '.join(map(str, game_chosen))
然而,你更大的问题是:

game_str = discord.Game(name=game_chosen)
您正在向discord.Game传递一个元组,您确定这是正确的吗?如果要像这样调用初始函数:
changegame(“传奇联盟”)
,则需要修复函数定义:

async def changegame(game_chosen: str)

我怀疑这就是你真正想要做的。

你想让它做什么?连接它们?什么是
异步定义*选择的游戏:str
?虽然有一个简单的答案,但很可能您应该向
changegame
传递一个名称,而不是多个参数。“你把这个函数称为什么?”两位炼金术士是的,答案是正确的,但@spectras是正确的。如果要将它们作为一个参数调用,为什么还要将其定义为多个参数?如果你只是把它们作为一个整体运行,它们之间的区别是什么?