以下
>>> re.sub(r'(\d+)', r'\1' * 2, 'test line 123')
与える
'test line 123123'
それを与える方法はありますか
'test line 246'
?
float()
強制は機能しません:
>>> re.sub(r'(\d+)', float(r'\1') * 2, 'test line 123')
could not convert string to float: \1
eval
またはしませんexec
。