本文介紹了Python TypeError:格式字符串的參數不足的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
這是輸出.我相信這些是 utf-8 字符串...其中一些可以是 NoneType 但它會立即失敗,在這樣的字符串之前...
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: 格式字符串的參數不足
TypeError: not enough arguments for format string
7 換 7?
推薦答案
請注意,用于格式化字符串的 %
語法已經過時了.如果你的 Python 版本支持它,你應該寫:
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.
這篇關于Python TypeError:格式字符串的參數不足的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!