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

        <bdo id='BaxAP'></bdo><ul id='BaxAP'></ul>

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

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

        不和谐机器人可以存储信息的地方在哪里[discor

        时间:2023-09-09

            <bdo id='IKjcs'></bdo><ul id='IKjcs'></ul>

          • <small id='IKjcs'></small><noframes id='IKjcs'>

              <tbody id='IKjcs'></tbody>
              <legend id='IKjcs'><style id='IKjcs'><dir id='IKjcs'><q id='IKjcs'></q></dir></style></legend>

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

                  <tfoot id='IKjcs'></tfoot>
                • 本文介绍了不和谐机器人可以存储信息的地方在哪里[discord.py]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我对 python 并不陌生,但对 discord.py 并不陌生.我试图通过 discord.py 手册,但没有找到可以在 discord 机器人上存储一些临时变量的位置.

                  I am not too new to python but new to discord.py. I have tried to go through the discord.py manual but did not find where I can store some temporary variable on a discord bot.

                  discord.py 手册:http://discordpy.readthedocs.io/en/最新/api.html

                  discord.py manual: http://discordpy.readthedocs.io/en/latest/api.html

                  例如,在 PHP SESSION 中,我们可以在 SESSION() 中存储信息.discord.py 有同样的东西吗?

                  For example, in PHP SESSION, we can store information on the SESSION(). Did discord.py has the same kind of things?

                  例如,如果我们有用户A"和用户B".A"将存储为A_Object"的对象,例如消息等.与B_Object"类似,但与A_Object"不同.在discord.py中,有没有这样的函数?

                  For example, if we have user "A" and user "B". "A" will be stored as an object of "A_Object", such as messages etc. Similar for "B_Object" but will be different from "A_Object". In discord.py, is there a function like that?

                  非常感谢您的帮助!

                  推荐答案

                  可以使用sqlite数据库.在你的定义里面写:

                  You can use sqlite database. Write inside your def:

                  # define database
                  import sqlite3
                  conn = sqlite3.connect("my_database.db")
                  cursor = conn.cursor()
                  # get stored object from database
                  sql = "SELECT * FROM my_table WHERE field_1=?"
                  cursor.execute(sql, [(value_1)])
                  data = cursor.fetchall()
                  # if object does not exist, create it
                  if len(data) == 0:
                      sql = "INSERT INTO my_table VALUES (?, ?)"
                      cursor.execute(sql, [(value_1), (value_2)])
                  # if stored object exist and we need update it
                  elif ...:
                      sql = "UPDATE my_table SET field_2 = ? WHERE field_1 = ?"
                      cursor.execute(sql, [(value_2), (value_1)])
                  else:
                      # get data from first object
                      value_of_field_1 = data[0][0]
                      # get data from third object
                      value_of_field_2 = data[2][1]
                  # close database connection
                  conn.commit()
                  conn.close()
                  

                  my_database.db - 是一个 sqlite db 文件,应该与 bot 的 .py 文件存储在同一文件夹中.

                  my_database.db - is a sqlite db file and should be stored in sa same folder with bot's .py file.

                  这篇关于不和谐机器人可以存储信息的地方在哪里[discord.py]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:AttributeError:“Bot"对象没有属性“add_roles&quo 下一篇:discord.py 如何添加静音命令

                  相关文章

                  最新文章

                • <small id='ZTbps'></small><noframes id='ZTbps'>

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