본문 바로가기
  • 紹睿: 자유롭고 더불어 사는 가치있는 삶

분류 전체보기193

[python 기초] python의 dictionary에 대하여 Ditionary{1:one, 2:two}mapping: key값을 가지고 찾음! 1. 기본적인 사용 방법: {}12345678910111213141516171819202122months = {1:'Jan', 2:'Feb', 3:'Mar', 4:'Apr', 5:'May', 6:'Jun', 7:'Jul', 8:'Aug', 9:'Sep', 10:'Oct', 11:'Nov', 12:'Dec'} print(months[1]) #Jan items = [('name', 'May'), ('birth', 5)]dict_items = dict(items)print(dict_items) # {'name': 'May', 'birth': 5}print(len(dict_items)) # 2 del dict_items['birt.. 2018. 6. 28.
[python 기초] python의 String에 대하여 String문자열 "~~"'~~'"""~~"""- input()을 이용하면 string으로 저장되었었음 1. Raw String: 특수 부호\n (next line)\t (tab만큼 이동)' "r'o': 불가침 영역으로 인정1234567891011121314151617path = "c:\temp"print(path) # c: emp # \를 이용print("c:\\temp") # c:\temp # \ escape sequencepath = 'c:\\program File\\python\\bin'print(path) # c:\program File\python\bin # r''이용print(r'c:\program File\python\bin') #c:\program File\python\bin #Let's.. 2018. 6. 27.
[python 기초] python의 tuple에 대하여 TupleTuple은 ()를 통해 만들거나, ","를 이용하여 만들 수 있다. 123456789101112131415161718192021222324a = 1b = 1,print(type(a), a) # 1print(type(b), b) # (1,) c = 4 * (20+5)d = 4 * (20+5,)print(type(c), c) # 100print(type(d), d) # (25, 25, 25, 25) e = [1, 2, 3]f = tuple(e)print(type(e), e) # [1, 2, 3]print(type(f), f) # (1, 2, 3) print(list('hello')) # ['h', 'e', 'l', 'l', 'o']print(tuple('hello')) # ('h', 'e', 'l.. 2018. 6. 27.
[python 기초] python의 list에 대하여 데이터 구조데이터를 일정한 기준(규칙)에 의해 모아 놓은 것 collection of data elements, structured in some way- built-in + 확장- Container type의 데이터 구조1) Sequence = mapping by element position (index) ex) List, String2) mapping = mapping by element name (key) ex) Dictionary built-in Sequence (내장)1) List2) Tuple3) String4) Buffer objects5) Xrange objects Sequence에 대한 주요 작업1) Indexing: 위치 [0 1 2]2) Slicing: 범위 지정해서 추출3) Add.. 2018. 6. 27.
[python 기초] 데이터 타입과 변수 데이터 타입과 변수1. 기본(Built-in)데이터 타입1) 숫자- Integers- Floats- Complex numbers- Booleans2) List, Tuple- List: 일종의 array- Tuple: Immutable(값이 변할 수 없음)3) String4) Dictionary- Keys- values5) Sets: 집합6) File Objects: File을 만들거나, 오픈 등등 자원관리 예제1. 일반 Type 1234567891011121314151617print("Hello world!")print("안녕하세요")print(type(20))print(type("20"))print(""" 'Oh no', she said""")print(10/3)print((-3)**4) Hello w.. 2018. 6. 26.
[python 기초] python 개요와 설치 Python 개요와 설치배경 - 1990년 후반 Guido van Rossum 개발 (네덜란드)- 오픈소스 cross-platform:General Public License(GPL)- ABC, Modula-3, C, C++, Algol-68, SmallTalk, Unix shell 등을 기반으로 개발 특징- High-level 언어- Interpreted 언어- Interactive 언어- 객체지향 언어- Scripting 언어 종류- Python or CPython written in C/C++version 2.7version 3-Jython: java for the JVM-IronPython: in C# for the .Net environment 개발환경- Python Interactive She.. 2018. 6. 26.