“ValueError:格式的零长度字段名称” Python 3.0,3.1,3.2中的错误 [英] "ValueError: zero length field name in format" error in Python 3.0,3.1,3.2

查看:442
本文介绍了“ValueError:格式的零长度字段名称” Python 3.0,3.1,3.2中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试学习Python(3更具体),我收到这个错误:

I'm trying learn Python (3 to be more specific) and I'm getting this error:

ValueError: zero length field name in format

我搜索了它,我发现你需要指定数字: / p>

I googled it and I found out you need to specify the numbers:

a, b = 0, 1
if a < b:
     print('a ({0}) is less than b ({1})'.format(a, b))
else:
     print('a ({0}) is not less than b ({1})'.format(a, b))

而不像教程(从lynda.com)实际上说:

And not like the tutorial (from lynda.com) actually says to do:

a, b = 0, 1
if a < b:
     print('a ({}) is less than b ({})'.format(a, b))
else:
     print('a ({}) is not less than b ({})'.format(a, b))

有Python 3.1和im使用3.2,我读到关于这个错误的是,这只发生在< 3.1(3.0)。他们在3.2中撤消了这个,还是我做错了什么?

The tutorial im following has Python 3.1, and im using 3.2 and what i read about this error is that this only happens in <3.1 (3.0). Did they undo this in 3.2, or am i doing something wrong?

另外,慢慢说话;)这是我第一个晚上学习Python,只有第二个脚本我用Python编写

Also, speak slowly ;) this is literally my first night learning Python and only the 2nd "script" i've written in Python.

推荐答案

我会猜测你是以某种方式意外运行python 2.6。

I'm gonna guess that you are running python 2.6 by accident somehow.

如果您使用python 3,此功能至少可以使用3.1,如果您使用的是python 2,则此功能仅适用于2.7。

This feature is only available for at least 3.1 if you are using python 3, or 2.7 if you are using python 2.

这篇关于“ValueError:格式的零长度字段名称” Python 3.0,3.1,3.2中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆