.py Python script
Text & source code
| MIME type | text/x-python text/x-python3 |
|---|---|
| Description | Python script |
| Category | Text & source code |
| Signature (magic bytes) | 23 21 20 2F 62 69 6E 2F 70 79 74 68 6F 6E (#! /bin/python)23 21 2F 62 69 6E 2F 70 79 74 68 6F 6E (#!/bin/python) |
| Based on | application/x-executable, text/plain |
| Other extensions | .pyx, .wsgi |
Frequently asked questions
What is a .py file?
The .py extension is used for several formats: Python script (text/x-python) and Python 3 script (text/x-python3).
How do I open a .py file?
With any text editor – Notepad++, Visual Studio Code, or gedit and vim on Linux. The file contains readable text, possibly source code or configuration.
How can you tell a genuine .py file?
By the bytes at the start of the file, the signature (magic bytes): 23 21 20 2F 62 69 6E 2F 70 79 74 68 6F 6E (#! /bin/python) and 23 21 2F 62 69 6E 2F 70 79 74 68 6F 6E (#!/bin/python). On Linux and macOS, file --mime-type example.py checks the real type regardless of the extension.
Which format is .py based on?
Technically a .py file is a subtype of “Executable” (application/x-executable), so programs for that base format can often read it too.
Which MIME type belongs to .py?
The MIME type is text/x-python. In the Apache web server: AddType text/x-python .py; in nginx: types { text/x-python py; }.