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

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

        <tfoot id='rfZTP'></tfoot>

      2. <small id='rfZTP'></small><noframes id='rfZTP'>

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

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

        字符串格式 JSON 字符串給出 KeyError

        String format a JSON string gives KeyError(字符串格式 JSON 字符串給出 KeyError)
          <tbody id='DE7PI'></tbody>
        <legend id='DE7PI'><style id='DE7PI'><dir id='DE7PI'><q id='DE7PI'></q></dir></style></legend>

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

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

                  <tfoot id='DE7PI'></tfoot>

                • 本文介紹了字符串格式 JSON 字符串給出 KeyError的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  為什么這段代碼會給出一個KeyError?

                  Why does this code give a KeyError?

                  output_format = """
                  { 
                      "File": "{filename}", 
                      "Success": {success}, 
                      "ErrorMessage": "{error_msg}", 
                      "LogIdentifier": "{log_identifier}" 
                  }
                  """
                  
                  print output_format.format(filename='My_file_name',
                                             success=True,
                                             error_msg='',
                                             log_identifier='123')
                  

                  錯誤信息:

                  KeyError: ' "File"'
                  

                  推薦答案

                  需要把外大括號加倍;否則 Python 認為 { "File".. 也是一個引用:

                  You need to double the outer braces; otherwise Python thinks { "File".. is a reference too:

                  output_format = '{{ "File": "{filename}", "Success": {success}, "ErrorMessage": "{error_msg}", "LogIdentifier": "{log_identifier}" }}'
                  

                  結果:

                  >>> print output_format.format(filename='My_file_name',
                  ...                            success=True,
                  ...                            error_msg='',
                  ...                            log_identifier='123')
                  { "File": "My_file_name", "Success": True, "ErrorMessage": "", "LogIdentifier": "123" }
                  

                  如果您正在生成 JSON 輸出,最好使用 json 模塊:

                  If, indicentally, you are producing JSON output, you'd be better off using the json module:

                  >>> import json
                  >>> print json.dumps({'File': 'My_file_name',
                  ...                   'Success': True,
                  ...                   'ErrorMessage': '',
                  ...                   'LogIdentifier': '123'})
                  {"LogIdentifier": "123", "ErrorMessage": "", "Success": true, "File": "My_file_name"}
                  

                  注意輸出中的小寫 true,按照JSON標準的要求.

                  Note the lowercase true in the output, as required by the JSON standard.

                  這篇關于字符串格式 JSON 字符串給出 KeyError的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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='eNxB3'></small><noframes id='eNxB3'>

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

                            主站蜘蛛池模板: 久久中文视频 | 国产一区二区三区四区区 | 男女爱爱福利视频 | 岛国毛片在线观看 | 91精品国产色综合久久不卡98 | 欧美精品a∨在线观看不卡 欧美日韩中文字幕在线播放 | 国产精品一区二区在线免费观看 | 国产精品久久国产精品99 | 精品久久久久久久久久久 | 日本网站免费在线观看 | 91精品国产91久久久久久吃药 | 久久lu | 国产精品视频免费观看 | 日韩综合在线视频 | 欧美男人亚洲天堂 | 亚洲一区精品视频 | 综合久久99 | 国产成人在线视频 | 精品久久久999 | 亚洲综合在线播放 | 成人性视频免费网站 | 久草久草久草 | 日韩中文一区 | 超碰在线播 | 九九热在线观看视频 | 国产一区二区三区在线看 | 亚洲看片| 色综合天天天天做夜夜夜夜做 | 久久久av中文字幕 | 一区二区三区四区在线视频 | 成人在线观看免费爱爱 | 91精品国产一区二区三区 | 中文字幕1区 | 久久日本| 欧美综合一区 | 亚洲一区二区三区四区五区午夜 | 黄色网页在线 | www.亚洲一区二区三区 | 操视频网站| 欧美国产日韩一区二区三区 | 国产综合网站 |