擅长:python、mysql、java
<p>因为每个项目都是由它的<code>"ID="</code>定义的,所以我使用这个术语来<code>split()</code>初始语句。你知道吗</p>
<p>然后就是在<code>"\n"</code>处<code>splitting</code>每个句子的问题,操纵一些字符串并<code>appending</code>将它们转换成一个<code>list</code>称为<code>results</code>。你知道吗</p>
<p><strong>代码:</strong></p>
<pre><code>s = 'ID=s4k5jk\nDate=8 December 1970\nTitle=crossing the atlantic on a tricycle\nID=f983\nDate=22 December 1970\nTitle=Royal Episode 13'
data = s.split("\nID=")
results = []
for d in data:
res = d.split("\n")
_id = res[0].replace("ID=", "")
_date = res[1].replace("Date=", "")
_title = res[2].replace("Title=", "")
results.append([_id, _date, _title])
for r in results:
print(r)
</code></pre>
<p><strong>输出:</strong></p>
<pre><code>['s4k5jk', '8 December 1970', 'crossing the atlantic on a tricycle']
['f983', '22 December 1970', 'Royal Episode 13']
</code></pre>