2

在 codacy 上,它检测到我没有足够的格式字符串参数的问题。请帮忙。

代码:

self.notify.error("An item we don't have: track %s level %s was selected." % [track, level]) 
4

2 回答 2

4

传递一个元组,而不是一个列表

self.notify.error("An item we don't have: track %s level %s was selected." % (track, level)) 
于 2015-11-23T17:27:19.350 回答
2

这就是我修复它的方法

"An item we don't have: track {} level {} was selected.".format(track, level)
于 2015-11-23T17:58:06.160 回答