题解 | #字符串分隔#

字符串分隔

https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7

import sys

for line in sys.stdin:
    line = line.strip()
    if line:
        round = len(line) // 8  #除以8,向下取整
        for i in range(0,round):
            print(line[i*8:i*8+8])
        if round*8 != len(line): #判断字符串是否非整数
            add_len = (round+1)*8 - len(line)  #取余数
            print(line[round*8::] + "0"*add_len)

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务