• <small id='YWgTS'></small><noframes id='YWgTS'>

  • <legend id='YWgTS'><style id='YWgTS'><dir id='YWgTS'><q id='YWgTS'></q></dir></style></legend>

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

      <tfoot id='YWgTS'></tfoot>

        ValueError:Python2.6.6 格式中的零长度字段名称

        时间:2023-06-06
        <legend id='jK4Q6'><style id='jK4Q6'><dir id='jK4Q6'><q id='jK4Q6'></q></dir></style></legend>

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

            <tfoot id='jK4Q6'></tfoot>

              1. <small id='jK4Q6'></small><noframes id='jK4Q6'>

                • 本文介绍了ValueError:Python2.6.6 格式中的零长度字段名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我使用这个 python shell 来生成一个字符串:

                  I use this python shell to generate a string:

                  >>>':'.join("{:x}
                  ".format(random.randint(0, 2**16 - 1)) for i in range(4))
                  

                  当我在 Python2.7.5 中运行这个 shell 时,一切正常.但是当 Python 版本为 2.6.6 时会发生 ValueError: zero length field name in format.当 Python 版本为 2.6.6 时,我应该怎样运行这个 shell?

                  When I run this shell in Python2.7.5, everything goes okay. But it occurs ValueError: zero length field name in format when Python version is 2.6.6. What should I run this shell fine when Python version is 2.6.6?

                  推荐答案

                  在 Python 2.6 或更早的版本中,您需要显式地为格式字段编号:

                  In Python versions 2.6 or earlier, you need to explicitly number the format fields:

                  ':'.join("{0:x}
                  ".format(random.randint(0, 2**16 - 1)) for i in range(4))
                  #          ^
                  

                  您可以在 docs 中阅读相关内容:

                  You can read about this in the docs:

                  在 2.7 版中更改:位置参数说明符可以省略,因此 '{} {}' 等效于 '{0} {1}'.

                  Changed in version 2.7: The positional argument specifiers can be omitted, so '{} {}' is equivalent to '{0} {1}'.

                  这篇关于ValueError:Python2.6.6 格式中的零长度字段名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 VSCode 中禁用 python 导入排序 下一篇:如何打印带有数千个分隔符的浮点数?

                  相关文章

                • <legend id='L81oi'><style id='L81oi'><dir id='L81oi'><q id='L81oi'></q></dir></style></legend>

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

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