题解 | #字符串分隔#

字符串分隔

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

while True:
    try:
        s = input().split()[0]
    except EOFError:
        break
        
    n = int(len(s)/8)
    
   #长度超过8
    for i in range(n):
        start  = i*8
        end  = (i+1)*8
        print(s[start:end].__str__())
        
    substr = s[n*8:len(s)]
    if not substr:#恰好是8的整数倍
        continue
    num  = 8 - len(substr)
    while num > 0:
        substr += '0'
        num -= 1
    print(substr.__str__())
        
        
        
        
        
全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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