gpt4 book ai didi

Python - 提取同一定界符的多个实例之间的行

转载 作者:行者123 更新时间:2023-11-28 21:16:00 27 4
gpt4 key购买 nike

我有这样一个文件

===
aa
bb
===
aa
cc
dd
==
11

我需要提取“===”之间的线并将它们放入不同的变量(可能是一个列表)。

你能帮帮我吗?谢谢

最佳答案

with open('input.txt') as input_file:
result = input_file.read().split('===\n')
print result

关于Python - 提取同一定界符的多个实例之间的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29376604/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com