001、
[root@PC1 test]# ls outcome.map test.py [root@PC1 test]# cat outcome.map ## 测试数据 55910 85204 jj 122948 yy kk 203750 rr ee ss 312707 dd ff 356863 [root@PC1 test]# cat test.py ## 测试脚本 in_file = open("outcome.map", "r") lines = in_file.readlines() print("lines: " + str(len(lines))) row = 0 for i in lines: i = i.strip().split("\t") row = row + 1 print(str(row) + ": " + str(len(i))) in_file.close() [root@PC1 test]# python test.py ## 执行程序,同时统计行数和列数 lines: 6 1: 1 2: 2 3: 3 4: 4 5: 3 6: 1
标签:python,PC1,lines,##,行数,列数,test,root,row From: https://www.cnblogs.com/liujiaxin2018/p/17033897.html