题解 | #字符串分隔#

字符串分隔

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

a = input()
b = list()
# 防止空格
a = a.replace(" ", "")
# 进行分割并装入到列表b中
while len(a) >= 8:
    b.append(a[0:8])
    a = a.replace(a[0:8], "")
# 对小于8的字符进行填充
while len(a) < 8 and len(a)>0:
    a += "0"
b.append(a)
#对列表进行遍历
for i in range(0, len(b)):
    print(b[i])

字符串虽然不能被修改但不妨碍我们对其进行覆盖操作,在这一方面,比元组好太多了,

全部评论

相关推荐

喜欢核冬天的哈基米很想上市:会爆NullPointerException的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务