본문 바로가기
프로그래밍/python

python json 파일 읽기

by 메이슨김 2016. 1. 3.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import json
 
CONFIG_FILE="config.json"
CONFIG = {}
 
#
def readConfig(filename):
    with open(filename) as json_config_file:
        js = json.load(json_config_file)
    return js
 
def main():
    global CONFIG_FILE
    global CONFIG
 
    # Read Config.json
    CONFIG = readConfig(CONFIG_FILE)
    print(CONFIG['KEY'])
 
#
if __name__ == "__main__":
    main()
cs


반응형

'프로그래밍 > python' 카테고리의 다른 글

리스트를 청크 단위로 나누기  (0) 2021.03.28
날짜 하루씩 더하기  (0) 2020.12.17
정규화  (0) 2020.12.17
list 에서 맨 뒤의 인덱스를 가져오는 방법.  (0) 2020.12.17