久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

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

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

    <legend id='BEYXc'><style id='BEYXc'><dir id='BEYXc'><q id='BEYXc'></q></dir></style></legend>

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

      1. <tfoot id='BEYXc'></tfoot>

        TypeError:TextIOWrapper 類型的對象不是 JSON 可序列化

        TypeError: Object of type TextIOWrapper is not JSON serializable(TypeError:TextIOWrapper 類型的對象不是 JSON 可序列化的)

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

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

                <tbody id='ntTHE'></tbody>

              1. <i id='ntTHE'><tr id='ntTHE'><dt id='ntTHE'><q id='ntTHE'><span id='ntTHE'><b id='ntTHE'><form id='ntTHE'><ins id='ntTHE'></ins><ul id='ntTHE'></ul><sub id='ntTHE'></sub></form><legend id='ntTHE'></legend><bdo id='ntTHE'><pre id='ntTHE'><center id='ntTHE'></center></pre></bdo></b><th id='ntTHE'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ntTHE'><tfoot id='ntTHE'></tfoot><dl id='ntTHE'><fieldset id='ntTHE'></fieldset></dl></div>
                  <bdo id='ntTHE'></bdo><ul id='ntTHE'></ul>
                • 本文介紹了TypeError:TextIOWrapper 類型的對象不是 JSON 可序列化的的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  如果代碼能夠正常工作,那么每當有人在聊天中鍵入內容時,他們就會獲得 5 經驗,并且該信息會被放入 .json 文件中,但當有人在聊天中鍵入內容時會發生這種情況聊天它給了我這個錯誤.

                  If the code was to work properly then whenever someone types something in the chat they get 5 experience and that information gets put into a .json file, but instead what happens is whenever someone types something into the chat it gives me this error.

                  on_message users = json.dumps(f) 
                  TypeError: Object of type TextIOWrapper is not JSON serializable
                  

                  這是我正在使用的代碼:

                  Here is the code that I am using:

                  import discord
                  from discord.ext import commands
                  from discord.ext.commands import Bot
                  import asyncio
                  import json
                  from json import dumps, loads, JSONEncoder, JSONDecoder
                  import os
                  
                  client = commands.Bot(command_prefix='^')
                  os.chdir(r'C:UsersquinyDesktopsauce')
                  
                  @client.event
                  async def on_ready():
                      print ("Ready when you are xd")
                      print ("I am running on " + client.user.name)
                      print ("With the ID: " + client.user.id)
                  
                  @client.event
                  async def on_member_join(member):
                      with open('users.json', 'r') as f: 
                          users = json.dumps(f)
                  
                      await update_data(users, member)
                  
                      with open('users.json', 'w') as f:
                          json.loads("users, f")
                  
                  @client.event
                  async def on_message(message):
                      with open('users.json', 'r') as f:
                          users = json.dumps(f)
                  
                      await update_data(users, message.author)
                      await add_experience(users, message.author, 5)
                      await level_up(users, message.author, message.channel)
                  
                      with open('users.json', 'w') as f:
                          json.loads("users, f")
                  
                  async def update_data(users, user):
                      if not user.id in users:
                          users[user.id] = {}
                          users[user.id]['experience'] = 0
                          users[user.id]['level'] = 1
                  
                  async def add_experience(users, user, exp):
                      users[user.id]['experience'] += exp
                  
                  async def level_up(users, user, channel):
                      experience = users[user.id]['experience']
                      lvl_start = users[user.id]['level']
                      lvl_end = int(experience ** (1/4))
                  
                      if lvl_start < lvl_end:
                          await client.send_message(channel, '{} has achieved a slightly higher 
                  level of {}, yay'.format(user.mention, lvl_end))
                          users[user.id]['level'] = lvl_end
                  

                  推薦答案

                  你有你的 加載dumps 向后,你應該使用 加載轉儲 代替(s 后綴表示這些函數適用于字符串.).load 從文件 dump 到文件

                  You have your loads and dumps backwards, and you should be using load and dump instead (the s suffix means those functions work on strings.). load from a file, dump to a file

                  users = {}
                  
                  @client.event
                  async def on_message(message):
                      # No need to load the dictionary, our copy is the most correct
                      await update_data(users, message.author)
                      await add_experience(users, message.author, 5)
                      await level_up(users, message.author, message.channel)
                      with open('users.json', 'w') as f:
                          json.dump(users, f)
                  
                  @client.event
                  async def on_ready():
                      print ("Ready when you are xd")
                      print ("I am running on " + client.user.name)
                      print ("With the ID: " + client.user.id)
                      # Load the json just once, when the bot starts
                      global users
                      with open('users.json') as f:
                          try:
                              users = json.load(f)
                          except:
                              users = {}
                  

                  這篇關于TypeError:TextIOWrapper 類型的對象不是 JSON 可序列化的的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How to make a discord bot that gives roles in Python?(如何制作一個在 Python 中提供角色的不和諧機器人?)
                  Discord bot isn#39;t responding to commands(Discord 機器人沒有響應命令)
                  Can you Get the quot;About mequot; feature on Discord bot#39;s? (Discord.py)(你能得到“關于我嗎?Discord 機器人的功能?(不和諧.py))
                  message.channel.id Discord PY(message.channel.id Discord PY)
                  How do I host my discord.py bot on heroku?(如何在 heroku 上托管我的 discord.py 機器人?)
                  discord.py - Automaticaly Change an Role Color(discord.py - 自動更改角色顏色)

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

                      • <legend id='oxwJE'><style id='oxwJE'><dir id='oxwJE'><q id='oxwJE'></q></dir></style></legend>

                      • <tfoot id='oxwJE'></tfoot>
                        • <bdo id='oxwJE'></bdo><ul id='oxwJE'></ul>

                          1. <i id='oxwJE'><tr id='oxwJE'><dt id='oxwJE'><q id='oxwJE'><span id='oxwJE'><b id='oxwJE'><form id='oxwJE'><ins id='oxwJE'></ins><ul id='oxwJE'></ul><sub id='oxwJE'></sub></form><legend id='oxwJE'></legend><bdo id='oxwJE'><pre id='oxwJE'><center id='oxwJE'></center></pre></bdo></b><th id='oxwJE'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='oxwJE'><tfoot id='oxwJE'></tfoot><dl id='oxwJE'><fieldset id='oxwJE'></fieldset></dl></div>
                              <tbody id='oxwJE'></tbody>
                            主站蜘蛛池模板: 91精品久久久久久久久久入口 | 九久久| h网站在线观看 | 欧美日韩成人 | 欧美一区二区三区在线 | 亚洲一区二区三区免费视频 | 国产精品久久久久久久模特 | 成人在线免费网站 | 四虎成人免费视频 | 日日操视频 | 亚洲视频在线免费观看 | a在线观看 | 国产一级片一区二区三区 | 日本高清视频在线播放 | 91黄在线观看 | 精品麻豆剧传媒av国产九九九 | xx性欧美肥妇精品久久久久久 | 一区二区三区四区五区在线视频 | 在线天堂免费中文字幕视频 | 毛片视频网站 | 日韩一区二区在线视频 | 国产精品国产自产拍高清 | 日韩毛片 | 91久久网站 | 久免费视频 | 日韩一区二区在线视频 | 欧洲免费视频 | 精品视频在线观看 | 免费久久精品视频 | 国产成人99久久亚洲综合精品 | 337p日本欧洲亚洲大胆精蜜臀 | 乱码av午夜噜噜噜噜动漫 | 国内久久精品 | 成人福利电影 | 日韩不卡一区二区 | 精品国产乱码久久久久久1区2区 | 国产色在线 | 精品国产欧美在线 | 国产精品成人国产乱一区 | 99久久免费观看 | 国产精品免费一区二区三区四区 |