脚本停止在第2689行读取文本文件,但文件更长
我正在逐行阅读文本文件,检查重复项,但是该脚本在第2689行中的文件中停止了一半。
import sys
doc = "people.txt"
lst = []
line_num = 0
with open(doc) as f:
with open(f"{doc}.cleaned", "w") as w:
for line in f:
if line not in lst:
lst.append(line)
w.write(line)
line_num = line_num + 1
print (line_num)
我是否在列表的最大长度上奔跑? 迭代器? 还有其他吗?
I am reading a text file line by line, checking for duplicates, but the script stops well less then half way through the file, at line 2689.
import sys
doc = "people.txt"
lst = []
line_num = 0
with open(doc) as f:
with open(f"{doc}.cleaned", "w") as w:
for line in f:
if line not in lst:
lst.append(line)
w.write(line)
line_num = line_num + 1
print (line_num)
Am I running up against a maximum length of a list?
An iterator?
Something else?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论