4 ms·
When I look at the website I currently only see "No items", but if you are using Python 3.6+ the pathlib[0] library has a very nice way of reading/writing files
by riezebos 6y ago
When I look at the website I currently only see "No items", but if you are using Python 3.6+ the pathlib[0] library has a very nice way of reading/writing files:
from pathlib import Path
p = Path("my_file.txt")
p.write_text("thing that needs to go into a file")
[0]https://docs.python.org/3/library/pathlib.html#pathlib.Path.write_text https://docs.python.org/3/library/pathlib.html#pathlib.Path....
- alex_portabella 6y agoIt seems up to me https://howtoxwithy.com/how-to/b35668da-7cbe-456f-8db5-0d64522fdd5d https://howtoxwithy.com/how-to/b35668da-7cbe-456f-8db5-0d645... That's the "Write to a file" item, I can see two Python examples there.
- riezebos 6y agoAh, this morning when I went to the site it only showed "No more items" no matter what I did. Now it shows "No more items" for 2 seconds and then starts showing items. I think the first example is what another commenter meant as unsafe. My example is under the hood doing exactly what the second (safe) example is doing, but without the need to use the context manager yourself.