Use os.path.getsize
:
>>> import os
>>> os.path.getsize("/path/to/file.mp3")
2071611
The output is in bytes.
More Related Contents:
- how to can i go over a file twice?
- How often does python flush to a file?
- Call a function from another file?
- How to read a file in reverse order?
- How to read a (static) file from inside a Python package?
- How to open a file using the open with statement
- How to write to a CSV line by line?
- How to check whether a file is empty or not
- How to open every file in a folder
- Why am I getting a FileNotFoundError?
- Stream large binary files with urllib2 to file
- Open file in a relative location in Python
- How can I separate the functions of a class into multiple files?
- How to find out whether a file is at its `eof`?
- How come a file doesn’t get written until I stop the program?
- Reading two text files line by line simultaneously
- filename and line number of Python script
- Search for a file using a wildcard
- Python append multiple files in given order to one big file
- Save a large file using the Python requests library [duplicate]
- How to add a key-value to JSON data retrieved from a file?
- How does python close files that have been gc’ed?
- Why do I get “Pickle – EOFError: Ran out of input” reading an empty file?
- How do I wrap a string in a file in Python?
- “TypeError: a bytes-like object is required, not ‘str'” when handling file content in Python 3
- Create a temporary FIFO (named pipe) in Python?
- Pydub (WindowsError: [Error 2] The system can not find the file specified)
- For loop not working twice on the same file descriptor [duplicate]
- f.read coming up empty
- Creating files and directories via Python