"파이썬 입문"의 두 판 사이의 차이
DB CAFE
(→변수) |
|||
19번째 줄: | 19번째 줄: | ||
complex | complex | ||
</source> | </source> | ||
+ | |||
+ | == 데이터 구조체 == | ||
+ | === 리스트 === | ||
+ | ==== create ==== | ||
+ | <source lang=python> | ||
+ | >>> names = [ ] | ||
+ | >>> names = [‘a’, ‘b’, ‘c’, ‘d, ‘e’] | ||
+ | </source> | ||
+ | ==== len(s) ==== | ||
+ | <source lang=python> | ||
+ | >>> names = [‘a’, ‘b’, ‘c’, ‘d, ‘e’] | ||
+ | >>> len(names) | ||
+ | 5 | ||
+ | </source> | ||
+ | ==== indexing ==== | ||
+ | <source lang=python> | ||
+ | >>> names = [‘a’, ‘b’, ‘c’, ‘d, ‘e’] | ||
+ | >>> names[0] | ||
+ | ‘a’ | ||
+ | >>> names[1] | ||
+ | ‘b’ | ||
+ | </source> | ||
+ | ==== append ==== | ||
+ | <source lang=python> | ||
+ | >>> names = [‘a’, ‘b’,’c’] | ||
+ | >>> names.append(‘d’) | ||
+ | >>> names | ||
+ | [‘a’, ‘b’, ‘c’, ‘d’] | ||
+ | </source> | ||
+ | ==== insert ==== | ||
+ | <source lang=python> | ||
+ | >>> names = [‘a’, ‘b’, ‘c’] | ||
+ | >>> names.insert(1, ‘e’) | ||
+ | >>> names | ||
+ | [‘a’, ‘e’, ‘b’, ‘c’] | ||
+ | </source> | ||
+ | ==== comprehension ==== | ||
+ | <source lang=python> | ||
+ | >>> data = [3, 4, 5] | ||
+ | >>> float_data = [float(d) for d in data] | ||
+ | </source> | ||
+ | |||
+ | === 튜플 === | ||
+ | === 딕셔너리 === | ||
+ | |||
+ | |||
== 문자열 조작 함수 == | == 문자열 조작 함수 == |
2020년 4월 10일 (금) 10:12 판
thumb_up 추천메뉴 바로가기
- DBA { Oracle DBA 명령어 > DBA 초급 과정 > DBA 고급 과정 }
- 튜닝 { 오라클 튜닝 목록 }
- 모델링 { 데이터 모델링 가이드 }
1 기본 문법[편집]
2 데이터 타입[편집]
# int
>>> a = 3
>>> type(a)
int
- float
- str
- bool
- complex
>>> c = 3 + 4j
>>> type(c)
complex
3 데이터 구조체[편집]
3.1 리스트[편집]
3.1.1 create[편집]
>>> names = [ ]
>>> names = [‘a’, ‘b’, ‘c’, ‘d, ‘e’]
3.1.2 len(s)[편집]
>>> names = [‘a’, ‘b’, ‘c’, ‘d, ‘e’]
>>> len(names)
5
3.1.3 indexing[편집]
>>> names = [‘a’, ‘b’, ‘c’, ‘d, ‘e’]
>>> names[0]
‘a’
>>> names[1]
‘b’
3.1.4 append[편집]
>>> names = [‘a’, ‘b’,’c’]
>>> names.append(‘d’)
>>> names
[‘a’, ‘b’, ‘c’, ‘d’]
3.1.5 insert[편집]
>>> names = [‘a’, ‘b’, ‘c’]
>>> names.insert(1, ‘e’)
>>> names
[‘a’, ‘e’, ‘b’, ‘c’]
3.1.6 comprehension[편집]
>>> data = [3, 4, 5]
>>> float_data = [float(d) for d in data]
3.2 튜플[편집]
3.3 딕셔너리[편집]
4 문자열 조작 함수[편집]
4.1 len(s)[편집]
>>> mystring = “hello world”
>>> len(mystring)
11
4.2 indexing[편집]
>>> mystring[0]
‘h’
4.3 slicing[편집]
>>> mystring[0:5]
‘hello’
>>> mystring[6:]
‘world’
4.4 문자열.split(S)[편집]
>>> companies = “yahoo google”
>>> companies.split(‘ ’)
[‘yahoo’, ‘google’]
4.5 in[편집]
>>> ‘google’ in companies
True
4.6 combining[편집]
>>> s1 = “hello”
>>> s2 = “world”
>>> s3 = s1 + ‘ ’ + s2
>>> s3
“hello world”
4.7 replace[편집]
>>> a = “yahoo;google”
>>> new_a = a.replace(‘;’, ‘-’)
>>> new_a
“yahoo-google”
4.8 index[편집]
>>> s = “yahoo google”
>>> s.index(“google”)
6
4.9 문자열.find(x)[편집]
>>> s = “yahoo google”
>>> s.find(“google”)
6
4.10 stripping[편집]
>>> a = “ yahoo ”
>>> new_a = a.strip()
>>> new_a
“yahoo”
5 파이썬 제어문[편집]
6 파이썬 모듈 임포트 방법[편집]
- import os
: 일반적인 import 방식
- from os import xxx
: xxx 함수만 import 하는 방식
- from os import *
: 모든 함수를 import 하는 방식
7 변수[편집]
https://drive.google.com/file/d/19QerDTdnDPaoVXjOAGYHyDnCnLx1UUUf/view?usp=drivesdk
>>> a = 10
>>> id(a)