# replace with your code here
import string
f = open('作业一素材.txt', 'r', encoding='utf-8')
text1= f.read()
y=text1.find('顺丰')
text2=text1[:y]
for c in string.punctuation:
text2=text2.replace(c,'')
def lengthOfLastWord(text3):
l=text3.split()
if len(l)==0:
return 0
else:return len(l[-1])
print(lengthOfLastWord(text2))
print(x)
1.去除页脚2.去除标点符号3.遍历处理过的文本,计算最后一个单词长度