728x90
1) 리스트 - 인덱스 0부터 시작, 음수 인덱스 : 뒤에서 ~번째
list_1=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
list_s1="Der Spiegel S.O.S"
[start:stop:step]
>>> print("list_1[7:15:3]= ", list_1[7:15:3])
list_1[7:15:3]= [7, 10, 13]
>>> print("list_s1[3::2] = ", list_s1[1:22:5])
list_s1[3::2] = ei S
[start:]
>>> print("list_1[9:] = ", list_1[9:])
list_1[9:] = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
>>> print("list_s1[8:] =", list_s1[8:])
list_s1[8:] = gel S.O.S
>>> print("list_s1[-4:] = ",list_s1[-4:])
list_s1[-4:] = .O.S
[:stop]
>>> print("list_1[:15] = ", list_1[:15])
list_1[:15] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
>>> print("list_s1[:7] = ", list_s1[:7])
list_s1[:7] = Der Spi
[::step]
>>> print("list_1[::7] = ", list_1[::7])
list_1[::7] = [0, 7, 14]
>>> print("list_s1[::2] = ", list_s1[::2])
list_s1[::2] = DrSiglSOS
[start:stop]
>>> print("list_s1[4:20] = ", list_s1[4:20])
list_s1[4:20] = Spiegel S.O.S
[start::step]
>>> print("list_1[5::2] = ", list_1[5::2])
list_1[5::2] = [5, 7, 9, 11, 13, 15, 17, 19]
>>> print("list_s1[2::4] = ", list_s1[2::4])
list_s1[2::4] = rilO
[:stop:step]
>>> print("list_1[:17:4] = ", list_1[:17:4])
list_1[:17:4] = [0, 4, 8, 12, 16]
>>> print("list_s1[:30:3] = ", list_s1[:30:3])
list_s1[:30:3] = D ieS.
2) 딕셔너리 - { 키:값 }
3) 집합
>>> set1={'a','b','c','d','e','f','g','h','i'}
>>> set2={'a','e','i','o','u'}
>>> set3={'z','y','x','w','v'}
>>> print(set1&set2)
{'i', 'e', 'a'}
>>> print(set2&set3)
set()
>>> print(set1|set2)
{'b', 'o', 'a', 'f', 'e', 'u', 'g', 'c', 'i', 'h', 'd'}
>>> print(set2|set3)
{'o', 'a', 'z', 'e', 'u', 'i', 'x', 'y', 'v', 'w'}
>>> print(set1-set2)
{'b', 'f', 'g', 'c', 'h', 'd'}
참고 : <개발자를 위한 파이썬 : 현장에서 일하는 개발자 맞춤 입문서 >
728x90
'공부하는삶 > Python' 카테고리의 다른 글
Python Composite pattern(composition), Descriptor, Meta class (0) | 2023.08.29 |
---|---|
Sequence (0) | 2020.05.09 |
Magic Method (0) | 2020.05.09 |
Gaussian Filter vs Bilateral Filter (0) | 2020.04.02 |
Python Multiprocessing module(파이썬 멀티프로세싱 모듈) (0) | 2019.11.28 |
Tensorflow 시작하기 - 1 (0) | 2019.11.28 |