题解 | #表示数字#
表示数字
http://www.nowcoder.com/practice/637062df51674de8ba464e792d1a0ac6
这可能我写的最痛苦的代码
while True: try: s = input() import re value = re.findall("\d+", s) if len(value) == 0: print(s) else: resindex = re.finditer("\d+", s) res = [] for i in resindex: res.append(i.span()) for i in range(len(value)): value[i] = "*" + str(value[i]) + "*" a = "" right = 0 for i in range(len(res)): left= res[i][0] a = a + s[right:left] a = a + value[i] right = res[i][1] a = a + s[res[-1][1]:] print(a) except: break