2024.4.9(周二)进度
完成个人作业用户使用说明书,录制演示视频,提交个人作业
python实验:
def getText():
txt=open("english.txt","r").read()
txt=txt.lower()
for ch in '~!@#$%^&*()_+"{}[]|?.<>?':
txt=txt.replace(ch,"")
return txt
hamletTxt=getText()
words=hamletTxt.split()
counts={}
for word in words:
counts[word]=counts.get(word,0)+1
items=list(counts.items())
print(len(items))
non_blank_count = 0
with open('english.txt') as infp:
for line in infp:
if line.strip():
non_blank_count += 1
print(non_blank_count)