Jump to content

Truncate a file: Difference between revisions

→‎{{header|Python}}: Used "with" statement, and changed to be a function
(Divide the task description into three paragraphs. Change a few words, but without changing the meaning of the task.)
(→‎{{header|Python}}: Used "with" statement, and changed to be a function)
Line 173:
 
=={{header|Python}}==
<lang python>#def Open a file for writingtruncate_file(fname, and truncate it to 1234 bytes.size):
"Open a file for writing, and truncate it to size bytes."
f = with open("file"fname, "ab") as f:
f.truncate(1234)
f.closetruncate(size)</lang>
 
=={{header|Ruby}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.