【发布时间】:2020-07-14 03:25:36
【问题描述】:
我有一个这样的字符串:
"initWithType:bundleIdentifier:uniqueIdentifier:"
还有两个这样的列表:
['long long', 'id', 'id']
['arg1', 'arg2', 'arg3']
并希望以字符串结尾:
"initWithType:(long long)arg1 bundleIdentifier:(id)arg2 uniqueIdentifier:(id)arg3"
如您所见,我实际上需要用每个列表中的第 n 个字符串替换每个第 n 个分号(加上一些带括号和空格的格式)。
我一直在尝试使用.format 和* 解包运算符,但收效甚微。
【问题讨论】:
标签: python python-3.x string list format