If you prefer doing it without any imports at all:
def wordlenghtsgrouper(phrase):
l = [len(w) for w in phrase.replace('.','').replace(',','').split()]
return {i:l.count(i) for i in l}
It returns a dictionary containing the "lengths" and a count of each ocurrence.
If you don't mind importing, you can use the Counter which is specifically does what you ask for:
from collections import Counter
...
def wordlenghtsgrouper(phrase):
return Counter([len(w) for w in phrase.replace('.','').replace(',','').split()])
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…