open()

Built-in FunctionPython 2.0+Beginner

Opens a file and returns a file object for reading or writing

Quick Info

Documentation
Official Docs
Python Version
2.0+

Learn by Difficulty

Quick Example

python
# open() creates a file object
# with open("file.txt", "w") as f:
#     f.write("Hello!")
print("open() is used for file I/O operations")

open() is a built-in function that opens a file and returns a file object for reading or writing.

Try in Playground

Tags

builtinfunctioncorefile-iocontext-manager

Related Items