1.保留空格string = ' # **'for i in range(0, len(string), 8): print(string[i:i+8])2.用0替代空格 1替代*s = " # **" x = "" for i in s:if i == ' ': x += '0' elif i == '\*': x += '1' else: x += i print(x)
Norman1z