Python 2.7 python中文件内的字符串比较

Python 2.7 python中文件内的字符串比较,python-2.7,Python 2.7,我需要用python编写一个脚本来查找第7行的输出,如果第一行为true(6c00ff00=1),那么第7行的输出为“y”。我能够在一个文件(比如“xyz”)中捕获所有这些值,但无法在该文件中进行比较 >>> vi xyz 6c00ff00 = 1 6c01ff00 = BGSV 1 6c02ff00 = 08IS01191025 6c03ff00 = 192.11.13.5 7005ff00 = g430 e808ff00 = 249 6c0aff00 = y 7002ff

我需要用python编写一个脚本来查找第7行的输出,如果第一行为true(6c00ff00=1),那么第7行的输出为“y”。我能够在一个文件(比如“xyz”)中捕获所有这些值,但无法在该文件中进行比较

>>> vi xyz

6c00ff00 = 1
6c01ff00 = BGSV 1
6c02ff00 = 08IS01191025
6c03ff00 = 192.11.13.5
7005ff00 = g430
e808ff00 = 249
6c0aff00 = y
7002ff00 = 35 .4  .0  /
7001ff00 = 0
7b00ff00 =
7100ff00 = 1
7003ff00 = 192.11.13.150

如果你的第一行是错的,谢谢你的回复。。。。我在执行上述操作时出错。。。文件“/scr.py”,如果line1.split('=')[1].strip()=='1'^syntaxer,则第14行。错误:语法无效help@user2885062:缺少一个
。现在修好了。查看编辑
with open('xyz') as infile:
  line1 = infile.readline().strip()
  for _ in xrange(6):
    line7 = infile.readline()
  line7 = line7.strip()
  print "The first line is '%s'" %line1
  print "The seventh line is '%s'" %line7
  if line1.split('=')[1].strip() == '1':
    if line7.split('=')[1].strip() == 'y':
      print "Correct"
    else:
      print "Wrong"