📜  在文件python代码示例中写入行数

📅  最后修改于: 2022-03-11 14:45:28.754000             🧑  作者: Mango

代码示例2
fname = "test.txt"
count = 0
with open(fname, 'r') as f:
    for line in f:
        count += 1
print("Total number of lines is:", count)