在Python 3(您似乎正在使用)中:
>>> sentence = "Hi my name is Bob">>> words = sentence.split()>>> average = sum(len(word) for word in words) / len(words)>>> average2.6

在Python 3(您似乎正在使用)中:
>>> sentence = "Hi my name is Bob">>> words = sentence.split()>>> average = sum(len(word) for word in words) / len(words)>>> average2.6