创建文本文件“七步诗.txt”,内容如下:
Pods burned to cook peas,
Peas weep in the pot:
Grown from same root, please,
Why boil us so hot?
统计并输出该诗的行数、单词数量
a = '''Pods burned to cook peas,
Peas weep in the pot:
Grown from same root, please,
Why boil us so hot?'''
print(len(a.split('\n')),len(a.split()))
不知道你这个问题是否已经解决, 如果还没有解决的话: