我需要一些关于我的代码的帮助。以下是我目前的问题:
- 当变量行匹配时,我需要在
numref
s 中获取匹配的值,示例如下。 - 我不确定我
if
是否正确构建了 -statement。
代码:
import subprocess
def p4 (base_num):
numrefs = ['nums/89/202089/4', 'nums/39/205739/2', 'nums/94/195594/6']
num_ignore = [150362, 147117, 147441, 143446, 200914]
''''
num_ids.txt
202089
205739
195594
202090
202092
202091
202084
202088
202086
202076
202083
206057
206056
'''
with open('./num_ids.txt', 'rb') as f:
# Iterate over the file itself
for line in f:
num = int(line)
if num > base_num and num not in num_ignore and line in numrefs:
#get the match when line matches numrefs
#if line is 20289,it should match the value nums/89/202089/ in num_refs and print it here,how can I do it?
print "OVER"
def main():
base_num=203456
p4(base_num)
if __name__ == '__main__':
main()