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

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

        <i id='eBNPp'><tr id='eBNPp'><dt id='eBNPp'><q id='eBNPp'><span id='eBNPp'><b id='eBNPp'><form id='eBNPp'><ins id='eBNPp'></ins><ul id='eBNPp'></ul><sub id='eBNPp'></sub></form><legend id='eBNPp'></legend><bdo id='eBNPp'><pre id='eBNPp'><center id='eBNPp'></center></pre></bdo></b><th id='eBNPp'></th></span></q></dt></tr></i><div id='eBNPp'><tfoot id='eBNPp'></tfoot><dl id='eBNPp'><fieldset id='eBNPp'></fieldset></dl></div>
        <legend id='eBNPp'><style id='eBNPp'><dir id='eBNPp'><q id='eBNPp'></q></dir></style></legend>
          <bdo id='eBNPp'></bdo><ul id='eBNPp'></ul>
      1. ValueError:python格式的零长度字段名称

        时间:2023-10-08
          <tbody id='Oqmal'></tbody>

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

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

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

                • 本文介绍了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格式的零长度字段名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

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

                  相关文章

                  最新文章

                  <tfoot id='NhNHo'></tfoot>

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

                      • <bdo id='NhNHo'></bdo><ul id='NhNHo'></ul>
                    2. <small id='NhNHo'></small><noframes id='NhNHo'>

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