gpt4 book ai didi

python - 在 python 2.5 中格式化字符串解压列表

转载 作者:行者123 更新时间:2023-11-28 20:52:21 25 4
gpt4 key购买 nike

有没有办法在 Python 2.5 中做这样的事情:

b = ('{!s}'*3)
b.format(*[i for i in xrange (3)])

因为这不起作用:

b = ('%s'*3)
b % (*[i for i in xrange (3)])

最佳答案

b = '%s' * 3
b % tuple(range(3))

关于python - 在 python 2.5 中格式化字符串解压列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6759700/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com