s = input("请输入一个包含整数的字符串:") s1 = ‘‘ number = ‘‘ index = 0 d = {} print(len(s)) for i in range(len(s)): c = s[i] if c.isdigit(): number += c else: if len(number) > 0: # ab34cd54ab45 ab{number0}cd{number1}ab s1 += "{{number{}:010}}".format(index) d[‘number‘ + str(index)] = int(number) index += 1 number = ‘‘ s1 += c if len(number) > 0: s1 += "{{number{}:010}}".format(index) d[‘number‘ + str(index)] = int(number) print(s1) print(s1.format_map(d))
原文地址:https://www.cnblogs.com/ppystudy/p/12146981.html
时间: 2024-10-03 22:22:16