题解 | 字符串分隔

字符串分隔

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

import sys

def split_str(input_str):
    long_str = len(input_str)
    need_zore_nubler=0
    if long_str%8 !=0:
        need_zore_nubler= 8-long_str%8
    temp_str = input_str + str(str(0)*need_zore_nubler)

    for i in range(0,len(temp_str)):        
        if i%8 == 0 and i!=0:
            print("\n"+temp_str[i],end='')
        else:
            print(temp_str[i],end='')

if __name__ == "__main__":
    input_str =input("")
    split_str(input_str)

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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