Anonymous user
Write entire file: Difference between revisions
→{{header|Python}}: Add method using Pathlib
(Added Pike implementation) |
(→{{header|Python}}: Add method using Pathlib) |
||
Line 608:
with open(filename, 'w') as f:
f.write(data)
</lang>
Starting in Python 3.4, we can use <code>pathlib</code> to reduce boilerplate:
<lang python>
from pathlib import Path
Path(filename).write_text(any_string)
Path(filename).write_bytes(any_binary_data)
</lang>
|