Python 如何同时遍历两个文件

fp1 = open("temp1.txt", "r")
fp2 = open("temp2.txt", "r")
while True:
    try:
        x = next(fp1)
        y = next(fp2)
    except StopIteration:
        break

 

 

参考文献:

http://www.runoob.com/python/python-func-next.html

posted @ 2018-10-12 10:55  jhc888007  阅读(836)  评论(0编辑  收藏  举报