程心妍的作业一

代码


f = open('作业一素材.txt', encoding = 'utf-8')
txt1 = f.read()
txt1 = txt1.replace('\n',' ')
result1 = txt1.split('.')
result2 = result1[36].split()
x = len(result2[14])
print("最后一个单词的长度为:",x)

结果

结果截图

解释