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

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

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

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

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

        格式:在字符串中使用大括號時出現(xiàn) KeyError

        Format: KeyError when using curly brackets in strings(格式:在字符串中使用大括號時出現(xiàn) KeyError)
        <tfoot id='tTgd0'></tfoot>
            <tbody id='tTgd0'></tbody>
        1. <small id='tTgd0'></small><noframes id='tTgd0'>

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

                  本文介紹了格式:在字符串中使用大括號時出現(xiàn) KeyError的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在運行以下代碼:

                  asset = {}
                  asset['abc'] = 'def'
                  print type(asset)
                  print asset['abc']
                  query = '{"abc": "{abc}"}'.format(abc=asset['abc'])
                  print query
                  

                  這會引發(fā) KeyError 錯誤:

                  [user@localhost] : ~/Documents/vision/inputs/perma_sniff $ python ~/test.py 
                  <type 'dict'>
                  def
                  Traceback (most recent call last):
                    File "/home/user/test.py", line 5, in <module>
                      query = '{"abc": "{abc}"}'.format(abc=asset['abc'])
                  KeyError: '"abc"'
                  

                  格式顯然被包裝 { 弄糊涂了.如何確保格式僅嘗試替換(正確的)內(nèi)部 {abc}.

                  Format is obviously getting confused by the wrapping {. How can I make sure format only tries to replace the (correct) inner {abc}.

                  即,預(yù)期的輸出是:

                  {"abc": "def"}
                  

                  (我知道我可以使用 json 模塊來完成這項任務(wù),但我想避免這種情況.我更愿意使用格式.)

                  (I'm aware I could use the json module for this task, but I want to avoid that. I would much rather use format.)

                  推薦答案

                  要插入文字大括號,請將其加倍:

                  To insert a literal brace, double it up:

                  query = '{{"abc": "{abc}"}}'.format(abc=asset['abc'])
                  

                  (在此處進行了記錄,但沒有特別明顯地突出顯示).

                  (This is documented here, but not highlighted particularly obviously).

                  這篇關(guān)于格式:在字符串中使用大括號時出現(xiàn) KeyError的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 中提供角色的不和諧機器人?)
                  Discord bot isn#39;t responding to commands(Discord 機器人沒有響應(yīng)命令)
                  Can you Get the quot;About mequot; feature on Discord bot#39;s? (Discord.py)(你能得到“關(guān)于我嗎?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 - 自動更改角色顏色)
                        <tbody id='nLfRx'></tbody>
                      • <bdo id='nLfRx'></bdo><ul id='nLfRx'></ul>
                        <i id='nLfRx'><tr id='nLfRx'><dt id='nLfRx'><q id='nLfRx'><span id='nLfRx'><b id='nLfRx'><form id='nLfRx'><ins id='nLfRx'></ins><ul id='nLfRx'></ul><sub id='nLfRx'></sub></form><legend id='nLfRx'></legend><bdo id='nLfRx'><pre id='nLfRx'><center id='nLfRx'></center></pre></bdo></b><th id='nLfRx'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='nLfRx'><tfoot id='nLfRx'></tfoot><dl id='nLfRx'><fieldset id='nLfRx'></fieldset></dl></div>

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

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

                            <tfoot id='nLfRx'></tfoot>
                            主站蜘蛛池模板: 免费av电影网站 | 色狠狠一区 | 隔壁老王国产在线精品 | 羞羞的视频网站 | 蜜臀久久99精品久久久久久宅男 | 天堂在线一区 | 色综合99| 爱综合| 精品欧美一区二区精品久久久 | 日韩有码一区二区三区 | 欧美黄色一区 | 免费一级黄色电影 | 中文字幕亚洲一区二区va在线 | 日中文字幕在线 | 日韩手机在线看片 | 国产精品久久久久久久白浊 | 天天看天天摸天天操 | 日韩精品一区二区三区在线观看 | 久久综合一区 | 亚洲aⅴ| 噜噜噜噜狠狠狠7777视频 | 国产亚洲精品一区二区三区 | 国产真实乱对白精彩久久小说 | 亚洲日本中文字幕在线 | 精品国产亚洲一区二区三区大结局 | 国产人成精品一区二区三 | 人人鲁人人莫人人爱精品 | 国产高清视频一区 | 欧美激情视频一区二区三区在线播放 | 欧美日韩国产一区二区三区 | 久久精品视频在线观看 | 日韩欧美网 | 色综合视频在线 | 亚洲成av人片在线观看无码 | 国产免费自拍 | 91久操视频| 成人黄色av | 国产精品欧美日韩 | 国产中文一区二区三区 | 国产精品免费福利 | 久热精品在线播放 |