pycharm运行时报错 IndexError: list index out of range

求帮忙!万分感谢!
中文分词模型代码报错:
sen_tags.append(data[1])
IndexError: list index out of range

报错的部分代码如下:


```python

def get_sens_tags(file):
    with open(file, 'r', encoding='utf8') as f:
    #with open('data/zhongyi.txt', 'r', encoding='utf8') as f:
        sens_tags = []
        sen_words = []
        sen_tags = []
        n_sens = 0
        #for line in f:
        for line in f.readlines():
            if not line.strip(): continue
            line = line.strip("\n")
            if line:
                data = line.split("\t")
                sen_words.append(data[0])
               sen_tags.append(data[1])  
            elif sen_words:
                n_sens += 1
                sens_tags.append((sen_words,sen_tags))
                sen_words = []
                sen_tags = []
        print('句子数量:%s' % n_sens)
    return sens_tags

```

根据你的描述
sen_tags.append(data[1])
IndexError: list index out of range
只有一种可能,data的下标溢出。根据你代码推断,你'data/zhongyi.txt'这个文件有一行不带\t(也就是文本文件按键盘tab键的值)。
你可以打印一下line的值确认一下。