import re x = open('作业一素材.txt',mode='r', encoding='utf-8') content = x.read() lines = content.splitlines() line = lines[-3] y = re.findall(r'\s(\w*).$', line) len_y = len(y[-1]) print(len_y)