import re
shuru = '''
20240814162319861000251227 厨房洗碗机上层打开加速 【 DoubleDishwasher 】 【 setMode 】 播报/ù没问题,洗碗机双层9代上层设好了
20240814162328540000146304 厨房洗碗机下层打开加速 【 DoubleDishwasher 】 【 setMode 】 播报/ù没问题,洗碗机双层9代下层设好了
20240814162337281000345303 厨房洗碗机上层关闭加速 【 DoubleDishwasher 】 【 cancelMode 】 播报/ù没问题,洗碗机双层9代上层已取消程序
20240814162345974000645310 厨房洗碗机下层关闭加速 【 DoubleDishwasher 】 【 cancelMode 】 播报/ù好的,洗碗机双层9代下层已取消程序
'''
def dealJG(shuru):
lines = shuru.split('\n')
lines = [line for line in lines if line.strip()]
shuru = '\n'.join(lines) # 删除多余的空白行
hang = shuru.count('\n') + 1
print('行数',hang)
shuru = shuru.replace('\n', ' ')
temp = re.sub(r'\s+', ' ', shuru) # 多空格都替换成1个
result = temp.strip().split(' ')
# print(result)
print('总共:', len(result))
jiange = int(len(result)/hang)
print('间隔:',jiange)
sn = []
text = []
other = []
for i in range(0,len(result),jiange):
sn.append(result[i])
text.append(result[i+1])
other.append(result[i+2])
return sn, text, other
if __name__ == '__main__':
sn, text, other = dealJG(shuru)
print(sn)
print(text)
print(other)
01-13
702
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
10-08
10万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-10
500
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-14
147
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-25