f = open('D:\python\作业一素材.txt',encoding='utf-8') txt = f.read() f.close() line1 = txt.splitlines() line2 = line1[-3] word = line2[-7:-1] length = len(word) print(length)
解释详见字里行间的注释