Last active
December 12, 2018 13:20
-
-
Save junhoyeo/7a43dc8c59d8bf2a3f3b9b5ee3fd9e59 to your computer and use it in GitHub Desktop.
JSON 문서 안 names 리스트의 정보 (지인분 도움)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
with open('something.json', 'r') as f: | |
data = json.load(f) | |
print(len(data['names'])) # 전체 names 리스트의 길이 | |
kinds = [] | |
for name in data['names']: | |
if name not in kinds: | |
print(name, data['names'].count(name)) # names 안의 한 name과 그 개수 | |
kinds.append(name) | |
print(*kinds) # names 리스트에 있는 모든 name의 종류 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
실행결과 예시
something.json
실행결과
Mv1 2
: Mv1은 2개 발견Mv2 1
: Mv2는 1개 발견Mv1 Mv2
: names 리스트 안에 있는 모든 name 종류(Mv1
,Mv2
의 2가지)