Answer the question
In order to leave comments, you need to log in
Why does the script for deleting lines from txt not work?
A small code to remove spent links from the general list:
with open("lots.txt", "r") as f:
lots = f.readlines()
print('All lots: {}\nTo removing: {}'.format(len(lots), len(loaded)))
for url in loaded:
try:
lots.remove(url.split(' ')[-1])
print('Removed: {}'.format(url.split(' ')[-1]))
except ValueError:
pass
with open("upd_lots.txt", "w") as new_f:
for lot in lots:
new_f.write(lot)
>>> print(type(lots))
<class 'list'>
>>> print(type(loaded))
<class 'list'>
>>>
All lots:
7812589
Answer the question
In order to leave comments, you need to log in
I needed to read the line like this: readlines() leaves behind \n .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question