티스토리 뷰

Python

python 문법 정리

송주환 2019. 1. 4. 09:51

zip동일한 개수로 이루어진 자료형을 묶어 주는 역할을 하는 함수이다.


ex) zip([1,2,3],[4,5,6])

->(1,4),(2,5),(3,6)


eye - np.eye() - 단위 행렬로 만들어줌(numpy 활용)

ex) C = np.eye(2) 

-> 2x2 identity matrix 


list 생성하는 다양한 방법

- a = [0] * 5

- a = [0,0,0,0,0]

- a = [0 for i in range(5)]


for _ in range

- 인덱싱을 무시하고 싶을 때 쓴다.

ex) for i in range(10):

print("hello world")

-> i가 쓰이지 않으므로  _를 쓴다. 


super().__init__

class Animal( ):
    def __init__( self, name ):
        self.name = name

class Human( Animal ):
    def __init__( self, name, hand ):
        super().__init__( name ) # 부모클래스의 __init__ 메소드 호출
        self.hand = hand

person = Human( "사람", "오른손" )


'Python' 카테고리의 다른 글

python 오류 정리  (0) 2019.01.11
python 슬라이싱  (0) 2019.01.07
pytorch 참고 자료  (0) 2019.01.06
가상환경 생성 변경 해제  (0) 2018.12.30
requirements  (0) 2018.12.28
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2025/08   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
글 보관함