You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
By clicking “Sign up for GitHub”, you agree to our
terms of service
and
privacy statement
. We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
text = input('请输入你要处理的文档:')
def stats_text_en(text):
text=text.replace('!',' ') #面对待处理的文档,没办法把可能出现的特殊字符都遍历一边然后替换,如果使用.isalpha()的话会把空格都删掉,该怎么办呢?
text=text.lower()
text=text.split()
dict1={}
for i in text:
j=text.count(i)
dict2={i:j}
dict1.update(dict2)
dict2=sorted(dict1.items(),key=lambda x:x[1],reverse=True)
print(dict2)
stats_text_en(text)