题解 | #字符串分隔#
字符串分隔
https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
string = input() n = len(string) full = "0" strings = [] groups = n // 8 for i in range(groups): i *= 8 s = string[i : i + 8] strings.append(s) if n % 8 != 0: a = n % 8 s = string[-a:] strings.append(s) g = len(strings) for i in range(g): if i == g - 1: other = 8 - len(strings[i]) new = strings[i] for _ in range(other): new = "".join([new, full]) else: new = strings[i] print(new)