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]