python的findall函数解决办法

python的findall函数
本人刚接触python,下面是我写的一段代码:(貌似出错误就出在这段上,别的我就不贴了,免得大家看的麻烦)

def get_hadoop_status():
    file = open("/usr/local/nagios/test.txt", 'r')
    dead_num = 0
    line = file.readline()
    while ('' != line):
        value = re.findall( '.*datanode[0-9]{1,2}[\t](\d).*', line)
        if (value == 1):
            dead_num += 1
        else:
            dead_num = dead_num
    file.close()
这段代码中的findall函数是用来匹配下面类型的数据的,我想读取每行最后一位是0还是1:
datanode1 0
datanode2 1
......
直接运行代码总是出现下面的错误:
Traceback (most recent call last):
  File "./check_datanode_alive", line 28, in ?
    get_hadoop_status()
  File "./check_datanode_alive", line 12, in get_hadoop_status
    if(1 == re.findall( '.*datanode[0-9]{1,2}[\t](\d).*', line)):
  File "/usr/lib64/python2.4/sre.py", line 167, in findall
    return _compile(pattern, flags).findall(string)
求大侠解答

------解决方案--------------------
貌似你是要对datanodeXX 1计数,文件不是过大的话,那就简单一次性操作:
def get_hadoop_status():
    f = open("/usr/local/nagios/test.txt", 'r')
    dead_num = len(re.findall(r'datanode\d+\s+1\D', f.read()))
    f.close()