循环问题
我正在编写一个程序来比较两个不同的文件。对于文件1中的每一行,我想将其与文件2中的所有行进行比较,然后转到文件1中下一行。下面的代码不会循环到文件1的下一行,有人能给我一些建议吗?
选择 | 换行 | 行号
- #! /usr/bin/env python
- import sys
- import fileinput
- # Open the two files
- f1 = open(sys.argv[1], "r")
- f2 = open(sys.argv[2], "r")
- for line in f1:
- chrR,chrStart,chrEnd,name,score,strand1,codingStart,codingEnd,itemRbg,blockCount,blockSize,BlockStart = line.strip().split()
- chr = range(int(chrStart), int(chrEnd))
- lncRNA = set(chr)
- for line in f2:
- chrC,clustStart,clustEnd,annote,score,strand = line.strip().split()
- clust = range(int(clustStart), int(clustEnd))
- cluster = set(clust)
- if strand1 == '-':
- if chrR == chrC:
- if strand1 == strand:
- if lncRNA & cluster:
- print name, annote, 'transcript'
- else:
- continue
- continue
- break