반응형
import json
def array_to_json_file(array, file_path):
"""
Converts an array to a JSON file.
:param array: List to be converted to JSON.
:param file_path: Path where the JSON file will be saved.
"""
# Convert the array to JSON format
json_data = json.dumps(array, ensure_ascii=False, indent=4)
# Write the JSON data to a file
with open(file_path, "w", encoding="utf-8") as file:
file.write(json_data)
# Example usage
array = #배열입력
file_path = "d:/test.json" #경로 지정
# Convert and save the array as a JSON file
array_to_json_file(array, file_path);
반응형
'Backend > Python' 카테고리의 다른 글
CSV파일 업로드 python코드 (0) | 2024.01.12 |
---|---|
Python 기본정보(2) (0) | 2023.12.20 |
Python 기본 정보(1) (0) | 2023.12.08 |
python 시작하기 (0) | 2023.12.04 |
Python 3.6 (0) | 2022.05.30 |