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

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

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

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

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

        如何為新的 python 格式選項設(shè)置可變精度

        How to set variable precision for new python format option(如何為新的 python 格式選項設(shè)置可變精度)
        <tfoot id='p7qKf'></tfoot>
          <bdo id='p7qKf'></bdo><ul id='p7qKf'></ul>
          <legend id='p7qKf'><style id='p7qKf'><dir id='p7qKf'><q id='p7qKf'></q></dir></style></legend>

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

                <tbody id='p7qKf'></tbody>
              <i id='p7qKf'><tr id='p7qKf'><dt id='p7qKf'><q id='p7qKf'><span id='p7qKf'><b id='p7qKf'><form id='p7qKf'><ins id='p7qKf'></ins><ul id='p7qKf'></ul><sub id='p7qKf'></sub></form><legend id='p7qKf'></legend><bdo id='p7qKf'><pre id='p7qKf'><center id='p7qKf'></center></pre></bdo></b><th id='p7qKf'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='p7qKf'><tfoot id='p7qKf'></tfoot><dl id='p7qKf'><fieldset id='p7qKf'></fieldset></dl></div>
                  本文介紹了如何為新的 python 格式選項設(shè)置可變精度的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我喜歡包含變量的字符串的新格式選項,但我希望有一個變量來設(shè)置整個腳本的精度,但我不知道該怎么做.舉個小例子:

                  I am loving the new format option for strings containing variables, but I would like to have a variable that sets the precision through out my script and I am not sure how to do that. Let me give a small example:

                  a = 1.23456789
                  out_str = 'a = {0:.3f}'.format(a)
                  print(out_str)
                  

                  現(xiàn)在這就是我想用偽代碼做的事情:

                  Now this is what I would want to do in pseudo code:

                  a = 1.23456789
                  some_precision = 5
                  out_str = 'a = {0:.(some_precision)f}'.format(a)
                  print(out_str)
                  

                  但我不確定,是否可能以及語法是否可能.

                  but I am not sure, if it is possibly and if it is possibly how the syntax would look like.

                  推薦答案

                  您可以嵌套占位符,其中嵌套的占位符可以在格式規(guī)范中的任何位置使用:

                  You can nest placeholders, where the nested placeholders can be used anywhere in the format specification:

                  out_str = 'a = {0:.{some_precision}f}'.format(a, some_precision=some_precision)
                  

                  我在那里使用了命名占位符,但您也可以使用編號插槽:

                  I used a named placeholder there, but you could use numbered slots too:

                  out_str = 'a = {0:.{1}f}'.format(a, some_precision)
                  

                  也支持嵌套槽(Python 2.7 及更高版本)的自動編號;編號仍然從左到右進(jìn)行:

                  Autonumbering for nested slots (Python 2.7 and up) is supported too; numbering still takes place from left to right:

                  out_str = 'a = {0:.{}f}'.format(a, some_precision)
                  

                  嵌套槽先被填充;當(dāng)前的實現(xiàn)允許您最多嵌套 2 層占位符,因此在占位符中使用占位符是行不通的:

                  Nested slots are filled first; the current implementation allows you to nest placeholders up to 2 levels, so using placeholders in placeholders in placeholders doesn't work:

                  >>> '{:.{}f}'.format(1.234, 2)
                  '1.23'
                  >>> '{:.{:{}}f}'.format(1.234, 2, 'd')
                  Traceback (most recent call last):
                    File "<stdin>", line 1, in <module>
                  ValueError: Max string recursion exceeded
                  

                  您也不能在字段名稱中使用占位符(因此不能將值動態(tài)分配給插槽).

                  You also can't use placeholders in the field name (so no dynamic allocation of values to slots).

                  這篇關(guān)于如何為新的 python 格式選項設(shè)置可變精度的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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='wrOHQ'><tr id='wrOHQ'><dt id='wrOHQ'><q id='wrOHQ'><span id='wrOHQ'><b id='wrOHQ'><form id='wrOHQ'><ins id='wrOHQ'></ins><ul id='wrOHQ'></ul><sub id='wrOHQ'></sub></form><legend id='wrOHQ'></legend><bdo id='wrOHQ'><pre id='wrOHQ'><center id='wrOHQ'></center></pre></bdo></b><th id='wrOHQ'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='wrOHQ'><tfoot id='wrOHQ'></tfoot><dl id='wrOHQ'><fieldset id='wrOHQ'></fieldset></dl></div>
                  <legend id='wrOHQ'><style id='wrOHQ'><dir id='wrOHQ'><q id='wrOHQ'></q></dir></style></legend>

                        <tbody id='wrOHQ'></tbody>

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

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

                            <tfoot id='wrOHQ'></tfoot>
                            主站蜘蛛池模板: 国产精品污www一区二区三区 | 午夜精品久久久久久久久久久久 | 视频一区中文字幕 | 亚洲区中文字幕 | 人人艹人人爽 | 中文字幕视频在线 | 日韩一区二区三区四区五区六区 | 激情小视频 | 成人高清视频在线观看 | 成人一区在线观看 | 国产精品久久久久久吹潮 | 成人精品鲁一区一区二区 | 嫩草影院黄 | 亚洲欧洲精品一区 | 亚洲视频一区在线观看 | 亚洲一区二区不卡在线观看 | 一级黄色大片 | 一区二区三区亚洲 | 国产激情视频在线观看 | 国产视频一区二区三区四区五区 | 亚洲第一黄色网 | 日本一区不卡 | 日韩电影中文字幕 | 18av在线播放 | 欧美理论在线观看 | 国产精品免费视频一区 | 成人在线观看免费视频 | 91亚洲欧美 | 嫩草伊人| 天堂成人国产精品一区 | 欧美啊v在线观看 | 欧美aaaaa | 国产一区久久 | 欧美在线精品一区 | 欧美在线视频观看 | 国产91丝袜在线播放 | 91福利影院 | 99久久婷婷 | 久久黄色网 | 99久久99| 亚洲精品久久区二区三区蜜桃臀 |