with open('rules_test1Fold0w4_sample00ll1.dat') as fileobj:
lines = list(fileobj)
actualrules=''
for index in sortrule:
print lines[index]
我有這段代碼打印出.dat文件的某些行,但是我想要做的是將每行都作爲陣列。 因此,舉例來說,如果我的文件中從文件中獲取數據並將其放入數組
`'Once upon a time there was a young
chap of the name of Peter he had a
great friend called Claus'`
過這樣的陣列將[Once upon a time there was a young,chap of the name of Peter he had a,great friend called Claus]
您發佈的代碼確實符合您的要求。你有問題嗎? –
我想你回答了你自己的問題 – Mibou
它打印出來的線條,它沒有把它放入數組 – miik