题解 | #表示数字#
表示数字
https://www.nowcoder.com/practice/637062df51674de8ba464e792d1a0ac6
# !/usr/bin/env python3 # -*- coding: utf-8 -*- __author__ = 'tianyi' __date__ = '2024/3/24 18:07 ' __file__ = 'HW_HJ96.py' import sys # 1. 读取输入 String1 = "" x=0 for n in sys.stdin.readline().rstrip(): if n.isdigit() and x == 0: String1+="*"+n x=1 elif n.isdigit() and x == 1: String1 += n else: if x == 1: String1 += "*"+n x = 0 else: String1 += n # if n is sys.stdin.readline().rstrip()[-1] and x == 1: # String1 += "*" if String1[-1].isdigit(): String1 += "*" print(String1)
sys.stdin.readline().rstrip()[-1] 为什么超出index边界