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

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

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

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

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

        如何遍歷多個 json 字典來檢查相同類型鍵的值?

        How do I iterate through multiple json dictionaries to check the value of the same type of key?(如何遍歷多個 json 字典來檢查相同類型鍵的值?)
        <tfoot id='VgQQO'></tfoot>

          <tbody id='VgQQO'></tbody>
            • <bdo id='VgQQO'></bdo><ul id='VgQQO'></ul>

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

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

                  <legend id='VgQQO'><style id='VgQQO'><dir id='VgQQO'><q id='VgQQO'></q></dir></style></legend>
                • 本文介紹了如何遍歷多個 json 字典來檢查相同類型鍵的值?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我希望能夠在多個 json 字典中獲取delta"的值.如果有任何改變,我正在使用來自 kivy 的 JsonStore.當(dāng)我按下啟動 check_streak 函數(shù)的按鈕時,我得到 NameError: name 'delta' is not defined.代碼如下:

                  I want to be able to get the value of "delta" in multiple json dictionaries. I'm using JsonStore from kivy if that changes anything. When I press the button that starts the check_streak function I get NameError: name 'delta' is not defined. Here is the code:

                  class MainApp(App):
                  
                      def build(self): # build() returns an instance
                          self.store = JsonStore("streak.json") # file that stores the streaks:
                  
                  
                          return presentation
                  
                      def check_streak(self, instance):
                  
                          for item in self.store.find(delta):
                  
                              if delta > time.time():
                                  print("early")
                  
                              if delta == time.time():
                                  print("on time")
                  
                              if delta < time.time():
                                  print("late")
                  

                  這是一個單獨(dú)文件中的 json 字典:

                  Here is the json dictionary in a seperate file:

                  {"first": {"action": "first", "action_num": "1", "seconds": 60, "score": 0, "delta": 1555714261.0438898}, "second": {"action": "second", "action_num": "2", "seconds": 120, "score": 0, "delta": 1555879741.894656}}
                  

                  我希望能夠從文件中的每個對象中獲取delta"的值.我該怎么做?

                  I want to be able to get the value of "delta" from every object put inside the file. How would I do this?

                  推薦答案

                  這個問題可以用item generator來得到'delta'的值.代碼如下:

                  This question can be solved with an item generator to get the value of 'delta'. Here is the code:

                  class MainApp(App):
                  
                      def build(self): # build() returns an instance
                          self.store = JsonStore("streak.json") # file that stores the streaks:
                  
                  
                          return presentation
                  
                      # Gets the value of delta (code I may never understand lol)
                      def item_generator(self, json_input, lookup_key):
                          if isinstance(json_input, dict):
                              for k, v in json_input.items():
                                  if k == lookup_key:
                                      yield v
                                  else:
                                      yield from self.item_generator(v, lookup_key)
                          elif isinstance(json_input, list):
                              for item in json_input:
                                  yield from self.item_generator(item, lookup_key)
                  
                      def check_streak(self, instance):
                          with open("streak.json", "r") as read_file:
                              data = json.load(read_file)
                              values = self.item_generator(data, 'delta')
                  
                  
                  
                          for honey in values:
                              if honey > time.time():
                                  print("early")
                  
                              if honey == time.time():
                                  print("on time")
                  
                              if honey < time.time():
                                  print("late")
                  

                  這篇關(guān)于如何遍歷多個 json 字典來檢查相同類型鍵的值?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  How to make a discord bot that gives roles in Python?(如何制作一個在 Python 中提供角色的不和諧機(jī)器人?)
                  Discord bot isn#39;t responding to commands(Discord 機(jī)器人沒有響應(yīng)命令)
                  Can you Get the quot;About mequot; feature on Discord bot#39;s? (Discord.py)(你能得到“關(guān)于我嗎?Discord 機(jī)器人的功能?(不和諧.py))
                  message.channel.id Discord PY(message.channel.id Discord PY)
                  How do I host my discord.py bot on heroku?(如何在 heroku 上托管我的 discord.py 機(jī)器人?)
                  discord.py - Automaticaly Change an Role Color(discord.py - 自動更改角色顏色)
                  <i id='awcRd'><tr id='awcRd'><dt id='awcRd'><q id='awcRd'><span id='awcRd'><b id='awcRd'><form id='awcRd'><ins id='awcRd'></ins><ul id='awcRd'></ul><sub id='awcRd'></sub></form><legend id='awcRd'></legend><bdo id='awcRd'><pre id='awcRd'><center id='awcRd'></center></pre></bdo></b><th id='awcRd'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='awcRd'><tfoot id='awcRd'></tfoot><dl id='awcRd'><fieldset id='awcRd'></fieldset></dl></div>
                    <tbody id='awcRd'></tbody>

                  • <tfoot id='awcRd'></tfoot>

                          <bdo id='awcRd'></bdo><ul id='awcRd'></ul>
                          <legend id='awcRd'><style id='awcRd'><dir id='awcRd'><q id='awcRd'></q></dir></style></legend>
                        • <small id='awcRd'></small><noframes id='awcRd'>

                            主站蜘蛛池模板: 中文字幕91av | 亚洲一区二区视频 | 午夜国产在线 | 韩日三级 | 久久精品国产久精国产 | av色站| 少妇特黄a一区二区三区88av | 91av视频| 国产成人精品一区二区三区网站观看 | 午夜激情在线视频 | 亚洲瑟瑟| 日韩中文在线视频 | 九色 在线 | 91中文字幕在线观看 | 成人免费共享视频 | 国产97视频在线观看 | 亚洲一区二区三区视频免费观看 | 日本超碰 | 欧美亚洲另类丝袜综合网动图 | 欧美一区二区三区在线 | 欧美亚洲一区二区三区 | 女生羞羞视频 | 欧美www在线 | 免费在线观看av网址 | 亚洲欧美高清 | 国产乱码高清区二区三区在线 | 日韩欧美专区 | 久草精品视频 | 久久99久久99 | 免费一区 | 国产精品久久久久久模特 | 最新国产在线 | 免费小视频在线观看 | 国产精品久久久久久妇女 | 在线一级片 | 成年人在线观看视频 | 欧美一级www片免费观看 | 日韩av在线免费 | 欧美日韩精品一区二区天天拍 | 国产精品久久久久久高潮 | 九九久久这里只有精品 |