Opens a file and returns a file object.
Syntax
open(file, mode?, encoding?)Example
Enter values below to update the example in real time.
open→encoding→write→content→read→print→Hello→World→# 파일 쓰기
with open("hello.txt", "w", encoding="utf-8") as f:
f.write("Hello, World!")
# 파일 읽기
with open("hello.txt", "r", encoding="utf-8") as f:
content = f.read()
print(content) # Hello, World!