TypeError:传递给Member的格式字符串不受支持。__format__

时间:2018-07-14 20:23:12

标签: python typeerror

    server = ctx.message.server
    msg = ""

    if server.id not in self.slowed_db:
        await self.bot.say(error("There isn't anyone in Slow Mode in this server."))
        return

    names = [server.get_member(x).name for x in self.slowed_db[server.id]]
    names_len = len(max(names, key=len))
    for key, value in self.slowed_db[server.id].items():
        try:
            member = server.get_member(key)
            msg += "{:<{names_len}} {}\n".format(member, value['seconds'], names_len=names_len)
        except AttributeError:  # User isn't in server
            continue
    if msg:
        await self.bot.say(box(msg, lang="css"))
    else:
        await self.bot.say(error("There isn't anyone in Slow Mode in this server."))
        return

谁能解释为什么这行不通?错误在此行上:

msg += "{:<{names_len}} {}\n".format(member, value['seconds'], names_len=names_len)

names_len可以很好地打印为整数,所以我很困惑。

1 个答案:

答案 0 :(得分:0)

我认为您想在此处传递member.name,而不是member本身。