王乐强的作业一

代码


import re
f = open('作业一素材.txt','r', encoding='utf-8')
txt = f.read()
f.close()
sentences = txt.split('\n')
lastsentence = sentences[-3]
words = lastsentence.split(' ')
lastword =words[-1][0:-1]
word_len = len(lastword)
print(word_len)

结果

结果截图

解释

早睡身体好,晚睡人会飘