题解 | #表示数字#re.sub()
表示数字
http://www.nowcoder.com/practice/637062df51674de8ba464e792d1a0ac6
import re
def plus_x(matched):
value = matched.group('value')
return ("*"+str(value)+"*")
while True:
try:
s = input()
# pattern = re.compile('\d+')
s = re.sub('(?P<value>\d+)',plus_x,s)
print(s)
except:
break
def plus_x(matched):
value = matched.group('value')
return ("*"+str(value)+"*")
while True:
try:
s = input()
# pattern = re.compile('\d+')
s = re.sub('(?P<value>\d+)',plus_x,s)
print(s)
except:
break