方法一:
while True:
try:
s=input()
s='a'+s+'a'
t=''
for i in range(1,len(s)-1):
if s[i].isdigit():
if not s[i-1].isdigit() and not s[i+1].isdigit():
t+='*'+s[i]+'*'
elif not s[i-1].isdigit():
t+='*'+s[i]
elif not s[i+1].isdigit():
t+=s[i]+'*'
else:
t+=s[i]
else:
t+=s[i]
print(t)
except:
break
方法二(参照):
while True:
try:
char_str = input()
pre_char =''
s=''
for i in char_str:
if i.isdigit():
if not pre_char.isdigit():
s+='*'
else:
if pre_char.isdigit():
s+='*'
s+=i
pre_char=i
if char_str[-1].isdigit():
s+='*'
print(s)
except:
break