with open(file_path, 'w') as file:
for i in range(1, 11):
data = "%d번째 줄입니다.\\n" % i
file.write(data)
with open(file_path, 'r') as file:
file.read() # 한번에 전체의 문자열을 전부 출력
file.readline() # 첫번째 의 문자열 출력
file.readlines() # 줄마다 리스트에 삽입하여 리턴
with open(file_path, 'a') as file:
file.write(data)
read txt file
with 구문 없이 read
with open(file_path,'w', encoding='utf-8') as file:
json.dump(abs_dict, file, ensure_ascii=False, indent=4)
import json
with open(f"{파일 경로}") as file:
json_file = json.load(file)
<aside> 💡 JSONDecodeError: Expecting value: line 1 column 1 (char 0)
</aside>