📅  最后修改于: 2022-03-11 14:45:18.848000             🧑  作者: Mango
fname = "gettysburg.txt"
num_lines = 0
num_words = 0
num_chars = 0
with open(fname, 'r') as f:
for line in f:
words = line.split()
num_lines += line.count(".")
num_words += len(words)
num_chars += len(line.replace(' ', ''))