Write entire file: Difference between revisions

m
→‎{{header|Python}}: Remove extra spacing
(→‎{{header|Python}}: Add method using Pathlib)
m (→‎{{header|Python}}: Remove extra spacing)
Line 605:
 
=={{header|Python}}==
<lang python>with open(filename, 'w') as f:
f.write(data)</lang>
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
from pathlib import Path
 
Path(filename).write_text(any_string)
Path(filename).write_bytes(any_binary_data)</lang>
</lang>
 
=={{header|Racket}}==
Anonymous user