一些小的字符串处理工具,但是就像写汉字的时候,容易提笔忘字,一时间想不起来。
# 按照字符串的指定的长度来进行截取
str2 = "123456789987654321123456789135792468"
res = []
while len(str2) > 0:
res.append(str2[:9])
str2 = str2[9:]
print(res)
# ['123456789', '987654321', '123456789', '135792468']
# 按照字符串的指定的长度来进行截取
str2 = "123456789987654321123456789135792468"
res = []
while len(str2) > 0:
res.append(str2[:9])
str2 = str2[9:]
print(res)
# ['123456789', '987654321', '123456789', '135792468']