티스토리 뷰
#Nesting Dictionary in a Dictionary
#여행지 기록, 나라와 방문한 도시 입력
trabel_log = {
"France": "Paris",
"Germany": "Berlin",
}
#여행지 기록, 나라와 방문한 도시들 입력
trabel_log = {
"France": ["Paris","London","Dijon"],
"Germany": ["Berlin","Hamburg","Stuttgart"],
}
#여행지 기록, 나라와 방문한 도시들, 방문한 회수 입력(도시들이 무얼 나타내는지 중첩된 Dictionary
trabel_log = {
"France": {"cities_visited": ["Paris","London","Dijon"], "total_visits": 12},
"Germany": {"cities_visited": ["Berlin","Hamburg","Stuttgart"], "total_visits": 5},
}
#cf. 중첩된 Lists도 가능하지만, 그 의미가 Dictionary보다 크지 않다
#List 내 Dictionary 중첩
#Nesting Dictionary in a List
ex)
[{
Key: [List],
key2: {Dictionary},
},
{
Key: Value,
key2: Value,
}]
trabel_log = [
{"country": "France", "cities_visited": ["Paris","London","Dijon"], "total_visits": 12},
{"country": "Germany", "cities_visited": ["Berlin","Hamburg","Stuttgart"], "total_visits": 5},
]
#가독성을 높이면
trabel_log = [
{
"country": "France",
"cities_visited": ["Paris","London","Dijon"],
"total_visits": 12
},
{
"country": "Germany",
"cities_visited": ["Berlin","Hamburg","Stuttgart"],
"total_visits": 5
},
]
'Test > Python(20220101~)' 카테고리의 다른 글
Days9_**비밀경매 프로그램 (0) | 2022.01.14 |
---|---|
Days9_리스트 속 딕셔너리에 데이터 추가 (0) | 2022.01.13 |
Day9_Dictionary, 점수를 가지고 등급 매기는 프로그램 (0) | 2022.01.12 |
Day9_Dictionaries, Nesting (0) | 2022.01.11 |
Day8_Caesar 암호 최종, 코드 재구성(하나의 함수로 정리) (0) | 2022.01.10 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- dp-2
- Join
- storage
- oracle
- dezoomify
- vmware.powercli
- fromkeys
- powercli
- LIST
- 부동없이
- vmware
- 배열
- powershell
- 읽어오기
- 3par
- virt-sysprep
- 스토리지
- exadata
- 차집합
- insert
- EXA
- 정렬
- set()
- cloud-init
- 중복제거
- artandculture
- dp-1
- sysprep
- 변수화
- 대소문자
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
글 보관함