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

Posted on In QA

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) 

Eric Ma

Eric is a 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.

2 comments

Leave a Reply

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