1. <legend id='eWbJ0'><style id='eWbJ0'><dir id='eWbJ0'><q id='eWbJ0'></q></dir></style></legend>

      <tfoot id='eWbJ0'></tfoot>
          <bdo id='eWbJ0'></bdo><ul id='eWbJ0'></ul>

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

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

        ValueError:python格式的零长度字段名称

        时间:2023-06-06

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

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

          <tbody id='WCpNk'></tbody>
          • <tfoot id='WCpNk'></tfoot>

                  <bdo id='WCpNk'></bdo><ul id='WCpNk'></ul>
                  <legend id='WCpNk'><style id='WCpNk'><dir id='WCpNk'><q id='WCpNk'></q></dir></style></legend>
                  本文介绍了ValueError:python格式的零长度字段名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  可能重复:
                  “ValueError: 格式中的零长度字段名称”Python 3.0,3.1,3.2 中的错误

                  我花了几个小时试图解决这个问题,但无济于事.我阅读了本指南.我还没有找到任何示例如何做我需要的.

                  I have spent hours trying to solve this problem but to no avail. I read this guide. I haven't found any examples how to do what I need.

                  运行脚本时出现此错误(部分省略):

                  When I run the script I get this error (partly omitted):

                  Traceback (...):
                     [...]
                     output.write("{: > 026,.18e} {: > 026,.18e}
                  ".format(x,y))
                  ValueError: zero length field name in format.
                  

                  代码是用 python 2.6 或 2.7 编写的,但我运行的是 python 3.1.我需要如何更改输出格式才能正常工作?

                  The code is written in python 2.6 or 2.7 but I run python 3.1. How would I need to change output format so that it would work?

                  def f(x,y,a = 0.01):
                      return y/(a+x)-y**3
                  
                  def ekspEuler(N,dat):
                      output = open(dat,"w")
                      h = 3.0/N
                      x,y = 0,1 #zac.pogoj
                  
                      for i in range(1,N+2):
                          output.write("{: > 026,.18e} {: > 026,.18e}
                  ".format(x,y))
                          y += h*f(x,y)
                          x = i*h
                      output.close()
                  

                  感谢您的帮助.

                  推荐答案

                  您可能运行的是旧的 Python 版本,而不是 3.1.在 Python 2.6 中,您需要格式规范中的索引,如下所示:

                  Chances are that you're running an old Python version, and not 3.1. In Python 2.6, you need indices in the format specs, like this:

                  "{0} {1}
                  ".format(x,y)
                  

                  将您的 Python 版本更新到最新版本,最好是 2.7 或 3.2,以解决问题.根据文档,省略数字索引 应该在 Python 3.1 中工作:

                  Update your Python version to a recent one, preferably 2.7 or 3.2, to fix the problem. According to the documentation, leaving out the numeric indices should work in Python 3.1:

                  3.1 版更改:位置参数说明符可以省略,因此{} {}"等同于{0} {1}".

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

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

                  上一篇:如何将 pandas 数据框的数据类型更改为具有定义格式的字符串? 下一篇:在 VSCode 中禁用 python 导入排序

                  相关文章

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

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

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