Python組み込み関数open
dict

open組み込み関数

enumerate

ファイルを開いてファイルオブジェクトを返します。

構文

open(file, mode?, encoding?)

使用例

下記の値を入力するとサンプルに即時反映されます。

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!