Think Python Exercise 9.1

编程写一个程序,使得它可以读取 words.txt ,然后只打印出那些长度超过20个字符的单词(不包括空格)。

1
2
3
4
5
6
fin = open('words.txt')

for line in fin:
    word = line.strip()
    if len(word) > 20:
        print(word)