Python - 为字符串格式化运算符解压缩列表的简短方法?

use*_*037 7 python string formatting tuples

不幸的是,*或**运算符的变化似乎不起作用:

lstData = [1,2,3,4]
str = 'The %s are %d, %d, %d, and %d' % ('numbers', *lstData)
Run Code Online (Sandbox Code Playgroud)

有一个简单的方法吗?

rpl*_*lnt 9

使用格式:

str = 'The {} are {}, {}, {}, and {}'.format('numbers', *lstData)
Run Code Online (Sandbox Code Playgroud)

有关可能的格式(浮点数,小数点,转换,...​​)的更多详细信息,请参阅文档.