Skip to content

Latest commit

 

History

History
25 lines (20 loc) · 410 Bytes

File metadata and controls

25 lines (20 loc) · 410 Bytes

File

with open("./hello.txt", mode="w+") as f:
    f.write("hello \n")

파일에 데이터 저장하기

f1 = open("./hello.txt", mode='r')
lines = f1.readlines()

print(lines)

여러줄 저장하기

import random

file_name = "./save_line.txt"
f1 = open(file_name, mode='w+')
for item in range(0, 10):
    f1.write(str(random.randint(1, 100)) + "\n")
f1.close()