如何从txt文件列表中读取元素(python)

如主题所述,我的python代码需要帮助。 当我用1输入ID时,它会打印出结果

“错误 没有” 我猜是None来自print(grp)。顺便说一句,我不熟悉(with..as ...)这种编码。我只知道[file = open('...','r')]种。.python的新功能

def hihi(ID):
  file=open('a.txt','r')
  iden=ID
  try:
        for line in file.readlines():
           line1=line.split('\t')
           if line1[1]==1:
               if (line1[0]==iden):
               grp=line1[3]
    file.close()
    return grp
    except:
        print('Error')
        return
ID=int(input('Enter ID'))
grp=hihi(ID)
print(grp)

“ a.txt”文件记录如下:

1 \ t a \ t 11 \ t ATO \ t 2 \ t y \ t 000 \ t aaa