with open('C:/Users/29847/Desktop/作业一素材.txt','r',encoding = 'utf-8') as file:
myString = file.read()
cnt = 0
for i in range(len(myString)-1,-1,-1):
if myString[i] == '\n':
cnt = cnt + 1
if cnt == 2:
break
length = 0
myString = myString[0:i]
lastWord = myString.split()[-1]
for j in lastWord:
if j.isalpha():
length += 1
print(length)
如果所写代码复杂,且没有良好的注释,那么请在这里补充解释。