我是python和编程的新手。我有两个文件要打开和文本过滤。直到这里我能做。但在那之后,现在我需要将这些结果存储在两个不同的二维矩阵(即。列表的列表),以便进一步计算。我做不到。
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()
不知道你在找什么,但这可能对你有帮助
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
矩阵[0]和矩阵[1]有从你的file1和file2处理的值