输入:
MECR-tree obtained using \textbf{MCAR-Miner} with $S_{\mathrm{U}} = data$ 25{\%} and $S_{\mathrm{L}} = string$ 12.5{\%}
将其更改为标题大小写,但在$ signs中免除文本。
输出应为:
Mecr-Tree Obtained Using \textbf{Mcar-Miner} With $S_{\mathrm{U}} = data$ 25{\%} And $S_{\mathrm{L}} = string$ 12.5{\%}
答案 0 :(得分:1)
这是一个假设$
字符将始终成对出现的示例:
sp = s.split('$')
for i, seg in enumerate(sp):
if i % 2 == 0:
sp[i] = seg.title()
print('$'.join(sp))
使用列表理解:
print(r'$'.join([seg.title() if not i % 2 else seg for i, seg in enumerate(s.split('$'))]))