Introduction To Python - Learn Python the hard way v2.0
voteup image
1

Will the truncate function always empty the entire file? Can we use it to empty only part of a file?

asked Oct 13, 2011

http://twitter.com/ragi_2's image

http://twitter.com/ragi_2

1 Answer:
voteup image
2

The truncate function will empty the entire file by default, but it also takes an argument which is the 'size'. If that argument is given then the first 'size' characters will be left out and the truncation will start from the 'size + 1' character till the end of the file.

More details here.

answered Oct 13, 2011

http://twitter.com/coding_insights's image

http://twitter.com/coding_insights

Provide an answer to this question.
This editor supports the markdown format. Please visit this page, If you are not familiar with Markdown.

Recent Course Updates: