001、
(base) root@PC1:/home/test2# cat outcome.ped ## 测试文件 1 G G C C G G 2 G G G C G G 3 G G C C G G 4 G G C C G G 5 G G C C G G 6 G G C C G G 7 G G C C G G 8 G G C C G G 9 G G G C G G 10 G G C C G G (base) root@PC1:/home/test2# cat x.py ## 测试脚本 #!/usr/bin/python in_file = open("outcome.ped", "r") ##first ## 第一次调用 for i in in_file: print(i.strip()) print("first") ##second for j in in_file: ## 第二次调用 print(j.strip()) print("second") (base) root@PC1:/home/test2# python x.py ## 执行程序,仅执行了第一次调用 1 G G C C G G first 2 G G G C G G first 3 G G C C G G first 4 G G C C G G first 5 G G C C G G first 6 G G C C G G first 7 G G C C G G first 8 G G C C G G first 9 G G G C G G first 10 G G C C G G first