Title: Bytes to Human Readable in Python - Runnable Code Snippet
Open Graph Title: Bytes to Human Readable in Python - Runnable Code Snippet
X Title: Bytes to Human Readable in Python - Runnable Code Snippet
Description: Convert bytes to human readable format (KB, MB, GB, etc.) for file sizes. Runnable Python snippet with live execution.
Open Graph Description: Convert bytes to human readable format (KB, MB, GB, etc.) for file sizes. Runnable Python snippet with live execution.
X Description: Convert bytes to human readable format (KB, MB, GB, etc.) for file sizes. Runnable Python snippet with live execution.
Keywords:
Opengraph URL: https://tempercode.dev/snippets/bytes-to-human-python
Domain: tempercode.dev
{"@context":"https://schema.org","@type":"SoftwareSourceCode","name":"Bytes to Human Readable","description":"Convert bytes to human readable format (KB, MB, GB, etc.) for file sizes.","programmingLanguage":"Python","text":"units = ['B', 'KB', 'MB', 'GB', 'TB']\ni = 0\nsize = bytes\nwhile size >= 1024 and i < len(units) - 1:\n size /= 1024\n i += 1\nf\"{size:.2f} {units[i]}\""}
| theme-color | #0c0d12 |
| color-scheme | dark |
| author | Temper |
| creator | Temper |
| publisher | Temper |
| og:image | https://tempercode.dev/og-image.png |
| og:type | article |
| twitter:card | summary_large_image |
| twitter:image | https://tempercode.dev/og-image.png |
Links:
Viewport: width=device-width, initial-scale=1