#作业一
file1=open('C:/Users/Lenovo/Desktop/作业一素材.txt','r',encoding='utf-8')
txt1=file1.read()
file1.close()
all_word=txt1.split()
last_word=all_word[-6].replace('.','')
word_length=len(last_word)
print('最后一个单词是:',last_word)
print('它的长度是:',word_length)
#作业一独附加
import re
file2=open('C:/Users/Lenovo/Desktop/作业一附加选做题素材.txt','r',encoding='utf-8')
txt2=file2.read()
file2.close()
sentences = re.split('。|!|?',txt2)
last_sentence=sentences[-2]
sentence_length=len(last_sentence)
print('最后一个句子是:',last_sentence)
print('它的长度是:',sentence_length)