文件搜索智能打开不工作

2024-10-02 20:41:00 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个关于python的代码,但它不起作用。 文件.seek(0)应该指向文件的开头;但它只指向行的开头一次

import smart_open
i=0
with smart_open.smart_open('s3://bkprav1/att1.txt','r') as fin1,smart_open.smart_open('s3://bkprav1/att2_ch2.txt','r') as fin2:      
        for line1 in fin1:
            i=i+1
            print(i)            
            print("line1")
            print(line1)
            j=0            
            for line2 in fin2:
                j=j+1
                print(j)
                print("line2")
                print(line2)
            fin2.seek(0)

Tags: 文件txtfors3smartasseekopen