久久久久久久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久久国产综合久久 | 一级中国毛片 | 北条麻妃99精品青青久久 | 国产做a爱免费视频 | 国产精品日韩一区 | 国产一区免费 | 成人在线免费观看 | 亚洲精品视频在线观看视频 | 国产91网站在线观看 | 亚洲一区网站 | 91精品久久久久久久久中文字幕 | 丝袜久久 | 91不卡| 久久天天 | eeuss国产一区二区三区四区 | 免费在线成人 | 91porn在线| 精品美女在线观看 | 国产 日韩 欧美 制服 另类 | 亚洲国产一区二区三区在线观看 | 成人午夜影院 | 国产精品不卡一区 | 国产日韩精品视频 | 亚洲视频中文字幕 | 青青草网站在线观看 | com.色.www在线观看 | 国产精品99久久久久久动医院 | 国产精品区二区三区日本 | 天天躁日日躁狠狠躁白人 | 亚洲女人天堂成人av在线 | 免费看国产片在线观看 | 高清国产一区二区 | 国产一区二区在线免费 | 日本aa毛片a级毛片免费观看 | 国产精品99久久久久久www | 国产精品乱码一区二区三区 | 日韩av在线免费 | 免费在线看a | 亚洲风情在线观看 |