More actions
No edit summary |
No edit summary |
||
| Line 132: | Line 132: | ||
=== 예외처리 === | === 예외처리 === | ||
` | |||
try: | try: | ||
except: | except: | ||
| Line 141: | Line 142: | ||
def error(self): | def error(self): | ||
raise NotImplementedError | raise NotImplementedError | ||
` | |||
=== 내장함수 === | === 내장함수 === | ||
* isinstance | * isinstance | ||
Revision as of 06:30, 1 May 2017
내용
git을 써보자
- clone
- commit
- push
- pull
- gitignore
python
자료형
- 숫자
- 정수
- 실수
- 8진수
- 16진수
- 문자열
- 큰따옴표
- 작은따옴표
- 큰따옴표 x 3
- 작은따옴표 x 3
- \(백슬래시) - 이스케이프 코드
- 인덱싱
- 포매팅(formatting)
- 단순 : %
- 고오오오오급 : {}
- 리스트 - []
- 인덱싱
- 슬라이싱
- 추가/삭제(del)
- 튜플 - ()
- 리스트와의 차이점 : 값 수정 x
- 딕셔너리 - {'key': 'value'}
- 집합 - set
- 특정 : 중복 허용x, 순서x
- 교집합, 합집합, 차집합 가능
- 참/거짓
- 참 : 1, not None(데이터가 있으면 무조건 참)
- 거짓 : 0, None(데이터가 없으면 무조건 거짓)
- 변수
- 사실은 모든건 객체
- getrefcount - 참조 개수
- id - 메모리 주소값
- del - 메모리에서 변수 삭제
- copy
- is
연산자
- '+'
- 숫자 : 더하기
- 문자열 : 다른 문자열 연결
- 리스트 : 합치기
- '-'
- 숫자 : 빼기
- '*'
- 숫자 : 곱하기
- 문자열 : 해당 문자열 n회 연결
- 리스트 : n회 반복
- '**'
- n ** m = pow(n, m), n^m
- '%' : 나누기 나머지
- '//' : 나누기 몫
제어문
- if
- if
- elif
- while
- while
- break
- continue
- 무한 루프 탈출 - `Ctrl+C`
- for
- for in
- range
함수
- def 함수명(인수): return 리턴값
- 인수값이 여러개? - *args
- 인수 초기값 설정
- 함수 밖의 변수를 건들고 싶다!
- return
- global
입출력
- 입력 - input
- 출력 - print
가상환경
- virtaulenv - pycharm에서 해보자
- pip
- get-pip.py
- show
- list
- freeze
- install/uninstall
- -r
- -m
클래스
- class 클래스명:
- 클래스 첫글자는 대문자 = class Service, class Person
- self
- init
모듈
- import 모듈이름
- from 모듈이름 import 모듈함수
- main
- `if __name__ == "__main__":`
패키지
- __init__.py
예외처리
` try: except:
pass
except 발생오류 as 오류 메시지 변수: else: finally:
def error(self):
raise NotImplementedError
`
내장함수
- isinstance
- id
- input/print
- lambda
- len
- list
- str
- type
외장함수
- sys
- os
- time
- random