I want to create a file of particular size (say, 1GiB). The content is not important since I will fill stuff into it.
What I am doing is:
f = open(\"
The question has been answered before. Not sure whether the solution is cross platform, but it works in Windows (NTFS file system) flawlessly.
with open("file.to.create", "wb") as out:
out.truncate(1024 * 1024 * 1024)
This answer uses seek and write:
with open("file.to.create", "wb") as out:
out.seek((1024 * 1024 * 1024) - 1)
out.write('\0')