<tfoot id='rQgls'></tfoot><legend id='rQgls'><style id='rQgls'><dir id='rQgls'><q id='rQgls'></q></dir></style></legend>

    • <bdo id='rQgls'></bdo><ul id='rQgls'></ul>

    <small id='rQgls'></small><noframes id='rQgls'>

      1. <i id='rQgls'><tr id='rQgls'><dt id='rQgls'><q id='rQgls'><span id='rQgls'><b id='rQgls'><form id='rQgls'><ins id='rQgls'></ins><ul id='rQgls'></ul><sub id='rQgls'></sub></form><legend id='rQgls'></legend><bdo id='rQgls'><pre id='rQgls'><center id='rQgls'></center></pre></bdo></b><th id='rQgls'></th></span></q></dt></tr></i><div id='rQgls'><tfoot id='rQgls'></tfoot><dl id='rQgls'><fieldset id='rQgls'></fieldset></dl></div>
      2. 如何使数据在 discord.py 中以表格形式显示?

        时间:2023-10-11
      3. <small id='smliB'></small><noframes id='smliB'>

            <bdo id='smliB'></bdo><ul id='smliB'></ul>
                  <tfoot id='smliB'></tfoot>
                  <i id='smliB'><tr id='smliB'><dt id='smliB'><q id='smliB'><span id='smliB'><b id='smliB'><form id='smliB'><ins id='smliB'></ins><ul id='smliB'></ul><sub id='smliB'></sub></form><legend id='smliB'></legend><bdo id='smliB'><pre id='smliB'><center id='smliB'></center></pre></bdo></b><th id='smliB'></th></span></q></dt></tr></i><div id='smliB'><tfoot id='smliB'></tfoot><dl id='smliB'><fieldset id='smliB'></fieldset></dl></div>
                    <tbody id='smliB'></tbody>
                  <legend id='smliB'><style id='smliB'><dir id='smliB'><q id='smliB'></q></dir></style></legend>

                  本文介绍了如何使数据在 discord.py 中以表格形式显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  您好,我正在创建一个制作积分表/排行榜的机器人,下面是非常好用的代码.

                  Hi I am creating a bot that makes points table/leaderboard , below is the code which works really nice.

                  def check(ctx):
                      return lambda m: m.author == ctx.author and m.channel == ctx.channel
                  
                  
                  async def get_input_of_type(func, ctx):
                      while True:
                          try:
                              msg = await bot.wait_for('message', check=check(ctx))
                              return func(msg.content)
                          except ValueError:
                              continue
                  
                  @bot.command()
                  async def start(ctx):
                      await ctx.send("How many total teams are there?")
                      t = await get_input_of_type(int, ctx)
                      embed = discord.Embed(title=f"__**{ctx.guild.name} Results:**__", color=0x03f8fc,timestamp= ctx.message.created_at)
                      
                      lst = []
                      
                      for i in range(t):
                          await ctx.send(f"Enter team {i+1} name :")
                          teamname = await get_input_of_type(str, ctx)
                          await ctx.send("How many kills did they get?")
                          firstnum = await get_input_of_type(int, ctx)
                          await ctx.send("How much Position points did they score?")
                          secondnum = await get_input_of_type(int, ctx)
                          lst.append((teamname, firstnum, secondnum))  # append 
                          
                      lstSorted = sorted(lst, key = lambda x: int(x[1]) + int(x[2],),reverse=True) # sort   
                      for teamname, firstnum, secondnum in lstSorted:  # process embed
                          embed.add_field(name=f'**{teamname}**', value=f'Kills: {firstnum}
                  Position Pt: {secondnum}
                  Total Pt: {firstnum+secondnum}',inline=True)
                  
                      await ctx.send(embed=embed)  
                  

                  结果如下所示:

                  但我想知道,我可以做些什么来获得表格形式的结果,例如团队名称、位置点数、总分、连续写的击杀分以及打印在它们下面的结果(我真的不知道,如果这让你明白我想说什么.)

                  But I want to know, can I do something to get the result in tabular form like The Team Name , positions points , total pts, kill pts written in a row and the results printed below them (I really don't if that made you understand what I am trying to say.)

                  下图帮助你理解,

                  所以我希望结果采用以下格式.我想不出办法,如果你能回答这个问题,请这样做,那将是一个非常大的帮助!谢谢.

                  So I want the result to be in following format. I can't think of a way doing it , if you can answer this please do so, That would be a very great help! Thanks.

                  推荐答案

                  这可能是你得到的最接近的:

                  This is probably the closest you will get:

                  embed.add_field(name=f'**{teamname}**', value=f'> Kills: {firstnum}
                  > Position Pt: {secondnum}
                  > Total Pt: {firstnum+secondnum}',inline=False)
                  

                  代码将输出如下内容:

                  我已将 inline 设置为 False 并将 > 字符添加到每个统计信息中.

                  I've set inline to False and added the > character to each of statistics.

                  这篇关于如何使数据在 discord.py 中以表格形式显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何从 tweepy 异步 on_status? 下一篇:我的 TEMPMUTE 命令出现一定错误

                  相关文章

                  最新文章

                    <tfoot id='GQayI'></tfoot>
                      <bdo id='GQayI'></bdo><ul id='GQayI'></ul>
                    <legend id='GQayI'><style id='GQayI'><dir id='GQayI'><q id='GQayI'></q></dir></style></legend>

                    <i id='GQayI'><tr id='GQayI'><dt id='GQayI'><q id='GQayI'><span id='GQayI'><b id='GQayI'><form id='GQayI'><ins id='GQayI'></ins><ul id='GQayI'></ul><sub id='GQayI'></sub></form><legend id='GQayI'></legend><bdo id='GQayI'><pre id='GQayI'><center id='GQayI'></center></pre></bdo></b><th id='GQayI'></th></span></q></dt></tr></i><div id='GQayI'><tfoot id='GQayI'></tfoot><dl id='GQayI'><fieldset id='GQayI'></fieldset></dl></div>

                  1. <small id='GQayI'></small><noframes id='GQayI'>