题解 | #字符串分隔#
字符串分隔
http://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
while True: try: s=input() if len(s)<=8: l=[] for i in s: l.append(i) for i in range(len(s),8): l.append(str(0)) for i in l: print(i,end='') if len(s)>8: if len(s)%8==0: list_num=(len(s)//8) else: list_num=(len(s)//8)+1 l=[[] for _ in range(list_num)] num1=0 num2=0 l[num1].append(s[0]) num2+=1 while num1<=(len(s)//8): if num2 > len(s) - 1: break while num2%8 !=0: if num2 > len(s) - 1: break l[num1].append(s[num2]) num2+=1 else: if num2 > len(s) - 1: break num1+=1 l[num1].append(s[num2]) num2+=1 while len(l[-1])<8: l[-1].append(str(0)) for i in range(len(l)): for j in range(8): print(l[i][j],end='') if i !=len(l)-1: print('') print('') except: break