我鑽進了以下問題:
鑑於以下結構的文件:
'>some cookies
chocolatejelly
peanutbuttermacadamia
doublecoconutapple
'>some icecream
cherryvanillaamaretto
peanuthaselnuttiramisu
bananacoffee
'>some other stuff
letsseewhatfancythings
wegotinhere
目的:投入
:含有「>」到列表作爲單個字符串每行代碼後的所有項
所以這個功能經過文件 的每一行,如果沒有的「>」它串接所有後續行的發生,並且如果「>」發生除去 的「\ n」, ,它會自動追加串接的字符串列表和「清除」字符串「序列」的串接下一序列
問題: 採取的輸入文件的例子,它只是把東西從「餅乾」和'一些冰淇淋「列入清單 - 但不是來自」一些其他的東西「。所以我們得到的結果如下:
[chocolatejelly
peanutbuttermacadamia
doublecoconutapple, cherryvanillaamaretto
peanuthaselnuttiramisu
bananacoffee] but not
[chocolatejelly
peanutbuttermacadamia
doublecoconutapple, cherryvanillaamaretto
peanuthaselnuttiramisu
bananacoffee, letsseewhatfancythings
wegotinhere]
這裏有什麼錯誤的想法?在我可能沒有注意的迭代中存在一些邏輯錯誤,但我不知道在哪裏。
在此先感謝您的任何提示!
道歉,並感謝Manoj Govindan的編輯! – Daniyal 2011-04-17 14:39:54