본문 바로가기
반응형

FullStack/22. Python9

파이썬 매뉴얼 # 파이썬 공식 문서https://docs.python.org/3/contents.html Python Documentation contentsWhat’s New in Python- What’s New In Python 3.12- Summary – Release highlights, New Features- PEP 695: Type Parameter Syntax, PEP 701: Syntactic formalization of f-strings, PEP 684: A Per-Interprete...docs.python.orghttps://docs.python.org/ko/3/contents.html Python Documentation contentsWhat’s New in Python- What’s Ne.. 2024. 7. 31.
데이터 딕셔너리 자료형 Key = Value 형식으로 Key에 대응하는 값을 표현할 수 있으며, 이러한 대응 관계를 연관 배열(Associative array) 또는 해시(Hash)라고 한다. >>> dic = {'key':'value', 'name':'Kai', 'age':'20'} >>> dic['key'] 'value' # Key는 정수값 가능 >>> a = {1:'a', 'b':2} >>> a[1] 'a' >>> a['b'] 2 # Value에는 다른 자료형도 가능 >>> a = {'a':[1,2,3]} >>> a['a'] [1, 2, 3] dic에 담긴 대응 관계 정보 Key Value key value name Kai age 20 딕셔너리 값 추가 >>> a = {1: 'a'} >>> a[2] = 'b' >>> a .. 2020. 12. 7.
데이터 튜플 자료형 튜플(tuple)은 몇 가지의 차이점을 제외하고는 리스트와 거의 비슷하다. 리스트는 []으로 감싸서 사용하지만, 튜플은 ()으로 사용 리스트는 그 값의 추가, 삭제, 수정이 가능하지만 튜플은 값을 변경할 수 없다. t1 = () t2 = (1,) # 한 개의 값만 가질 경우 , 필수 t3 = (1,2) t4 = 1,2,3 # ()를 생략 할 수 있다. t5 = (1,2,3,('a','b')) # 튜플안에 또 다른 튜플이 가능 튜플은 요소값을 수정, 삭제하려면 오류 발생 >>> t1 = (1, 2, 'a', 'b') >>> del t1[0] Traceback (most recent call last): File "", line 1, in TypeError: 'tuple' object doesn't supp.. 2020. 12. 7.
[Python] matplotlib 그래프 한글 깨짐 matplotlib 그래프 한글 깨짐 matplotlib을 이용하여 그린 그래프에서 한글이 깨져서 표시가 된다. 해당 현상을 피하려면 Font를 변경해줘야 한다. 현상 import matplotlib import sys import pandas as pd df = pd.read_csv('data/score.csv') df.index = df['이름'] df['국어'].plot(kind='bar') 수정 import matplotlib import platform print(platform.system()) # 플랫폼 확인 # Window if platform.system() == 'Windows': matplotlib.rc('font', family='Malgun Gothic') elif platform.. 2020. 11. 28.
반응형