参考其他同学的答案,做了优化:
- 通过不断更新起始位置打印出长度为8的字符串
- 通过str.ljust()方法补齐指定内容到指定长度
temp = input()
start = 0
end = 8
for i in range(len(temp)):
if end < len(temp):
print(temp[start:end])
start = start + 8
end = end + 8
else:
print(temp[start:end].ljust(8, "0"))
break