Search code examples
pythonstringformattypeerror

Python TypeError: not enough arguments for format string


Here's the output. These are utf-8 strings I believe... some of these can be NoneType but it fails immediately, before ones like that...

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

TypeError: not enough arguments for format string

Its 7 for 7 though?


Solution

  • 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.