I'd really recommend that you work your way through some Python
Tutorials (you can find tons online) and also check out our ObsPy
teaching resources. See links on this page:
You can also check out the 1 hour IRIS webinar on youtube:
And some more Jupyter notebooks from ObsPy training courses, one of the
most recent courses is here:
The main problem with your code (aside from the fact that you keep
posting invalid Python code) is that you keep overwriting your files in
the loop because the filenames are not unique across the loop. So you
should try something like..
for tr in stream:
filename = '%s_%s.mseed' % (
tr.id, tr.stats.starttime.strftime('%Y-%m-%dT%H%M%S'))
tr.write(filename, format='mseed')
If you want to post more questions please take at least the time to post
syntactically valid Python code that you verified locally on your computer.