find the size of a json file in python

To find the size of a JSON file in Python, you can use the following code:

main.py
import os

filename = 'path/to/your/json/file.json'
filesize = os.path.getsize(filename)

print(f'The size of {filename} is {filesize} bytes')
143 chars
7 lines

Here, we are using the os.path.getsize() function to get the size of the file, in bytes. We pass the file path as an argument to this function. Finally, we print out the size of the file, along with the filename.

gistlibby LogSnag