2018 Amazon Jeff bezos1120 能用什么函数,实现效果,将数字用[]括起来?
循环判断就行了,什么函数也用不上
要么就正则匹配
a='2013abcd1234dcba'
b=str()
d=0
for x in a:
if x.isdigit() and d==0:
b+='['
d=1
elif not x.isdigit() and d==1:
b+=']'
d=0
b+=x
print(b)