file.truncate() | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 1

file.truncate()

what does file.truncate() exactly do ?

21st Oct 2016, 8:28 AM
Sunera
Sunera - avatar
2 Réponses
+ 3
It truncates everything past what you have already read. https://www.tutorialspoint.com/JUMP_LINK__&&__python__&&__JUMP_LINK/file_truncate.htm
21st Oct 2016, 11:43 AM
Zen
Zen - avatar
+ 3
...and one way people use it is to immediately 'zero' a file without actually deleting it (and then losing its name or position in the file system); sometimes specifically because it's faster.
22nd Oct 2016, 6:38 AM
Kirk Schafer
Kirk Schafer - avatar