Why “ValueError: zero length field name in format” error in Python on CentOS 6?

The same Python program runs without any problem while it report

ValueError: zero length field name in format

error in Python on CentOS 6

The piece of code in Python is:

print '== {} SPF'.format(d) 

Why “ValueError: zero length field name in format” error in Python on CentOS 6?

This feature of {} without the position argument specifier is only available after at least 3.1 for Python 3, or 2.7 for Python 2.

On CentOS 6, the default Python version is 2.6:

$ python --version
Python 2.6.6

So you need to add the position argument specifiers:

print '== {0} SPF'.format(d) 
Answered by Eric Z Ma.

Eric Z Ma

Eric is a father and systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *