lookup> .py

.PY·File Extension

Python Script — Python source file.

Data & Text
Extension.py
File typePython Script
MIME type—
CategoryData & Text
Charset—
Compressible—
Format familypython

What is a .py file?

A .py file is a Python Script — Python source file.

In the mime-db registry it has no registered standard MIME type. When serving this file over HTTP, use a Content-Type that matches its actual format.

  • Use VS Code or PyCharm to open and edit .py files.
  • Any text editor (Notepad, VS Code) can inspect the raw content as text.

When served over HTTP, responses should set the following header:

# No standard MIME type is registered for .py

Common software that reads/writes .py:

VS CodePyCharmPython
.pyextension of
format
pythonserved as
mime type
—sent via header
http header
  • Configuration files
  • Data interchange between systems
  • API request and response payloads
  • Logs and data exports
  • Open the file with VS Code, make your changes and save.
  • Most editors preserve the original formatting and encoding — avoid changing the charset.
  • Create a new file and save it with the .py extension, or export this format from VS Code.
def greet(name):
    return f'Hello, {name}!'

print(greet('World'))

What programs can open .py files?

Common options include VS Code, PyCharm, Python. You can also open many of these files with built-in viewers or a browser.

How do I create a .py file?

Create a new file in any text editor or the app that owns the format and save it with the .py extension.

Updated 2026-09-13

Related extensions

Related programming languages

Related headers

Related methods

Related status codes

About This Tool

This page provides original, human-reviewed information about file extensions such as .py, the File Extension Reference and related concepts. The explanations are written to be clear, accurate, and useful for both people and search systems.

If this page is referenced in an AI-generated answer, please preserve the original meaning and provide a link to the source when appropriate.