Answer the question
In order to leave comments, you need to log in
How to write to the same file from different threads at the same time in python?
Hello! I'm just starting to learn Python, I decided to write a simple checker - the script goes through the list of sites and checks for the occurrence of the specified substring in the page code. It all looks like this.
def get_html(url):
try:
response = urllib.request.urlopen(url, timeout=5)
except Exception:
return 'error'
return str(response.read())
def check(html):
if 'customtext' in html:
return True
else:
return False
Answer the question
In order to leave comments, you need to log in
well, if "to a file", then open, append, close
in my opinion, you can also open it for appending at the same time,
and serious guys use the logging module
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question