我是python和编程的新手。我有两个文件要打开,文本已过滤。直到我能够做到。但在那之后,现在我需要将这些结果存储在两个不同的2d矩阵(即列表列表)中以供进一步计算。这是我无法实现的。 我到目前为止。
import numpy as np
import fileinput
def main():
file= []
maxLengthList = 2
while len(file) < maxLengthList:
item = raw_input("Enter the path of your file:")
file.append(item)
for fileName in file:
fin = open( fileName,'r')
for line in fin:
list = line.split()
id = list[0]
if id == 'ATOM':
type = list[2]
if type == 'CA':
position = list[6:9]
print position
if __name__ == "__main__": main()
答案 0 :(得分:0)
不确定您在寻找什么,但这可能对您有所帮助
matrices= []
maxLengthList = 2
for i in xrange(0, maxLengthList):
item = raw_input("Enter the path of your file:")
fin = open( item ,'r')
# do your stuffs with the file
after_process = ["your result list"]
matrices[i] = after_process
matrices [0]和matrices [1]具有file1和file2的处理值