#Import os Library
import os
# open file
fd = os.open("test.txt", os.O_RDWR)
#Print original size of file (in bytes)
print("File size (in bytes):", os.stat(fd).st_size)
length = 10
#Truncate file to 10 bytes
os.ftruncate(fd, length)
#Print new size of file (in bytes)
print("File size (in bytes):", os.stat(fd).st_size)
#close file
os.close(fd)