题解 | #字符串分隔#
字符串分隔
https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
# 定义一个最终拼接好的字符串 new_str = "" # 输入原始字符串 string = input() # 对字符串进行求余和商 shang, yushu = divmod(len(string), 8) # 拼接完整的字符串 string = string + "0" * (8 - yushu) if yushu else string # 进行字符串重组 for index in range(0,len(string),8): new_str += string[index:index + 8] + "\n" print(new_str)