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