Форум сайта python.su
4
Нужно заменить “US1234567” на “US 1,234,567”
Делаю
print(re.sub("US([0-9])([0-9][0-9][0-9])([0-9][0-9][0-9])","US \1\2\3","In US1234567 we can notice..."))
In US [здесь идут квадраты] we can notice...
Офлайн
43
re.sub('\d+',lambda m: ' {:,}'.format(int(m.group(0))) ,"In US1234567 we can notice...") Out[57]: 'In US 1,234,567 we can notice...'
Офлайн