Python TypeError: not enough arguments for format string Python TypeError: not enough arguments for format string python python

Python TypeError: not enough arguments for format string


You need to put the format arguments into a tuple (add parentheses):

instr = "'%s', '%s', '%d', '%s', '%s', '%s', '%s'" % (softname, procversion, int(percent), exe, description, company, procurl)

What you currently have is equivalent to the following:

intstr = ("'%s', '%s', '%d', '%s', '%s', '%s', '%s'" % softname), procversion, int(percent), exe, description, company, procurl

Example:

>>> "%s %s" % 'hello', 'world'Traceback (most recent call last):  File "<stdin>", line 1, in <module>TypeError: not enough arguments for format string>>> "%s %s" % ('hello', 'world')'hello world'


Note that the % syntax for formatting strings is becoming outdated. If your version of Python supports it, you should write:

instr = "'{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}'".format(softname, procversion, int(percent), exe, description, company, procurl)

This also fixes the error that you happened to have.


I got the same error when using % as a percent character in my format string. The solution to this is to double up the %%.