ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [Python_Basic]리스트 배열
    Python/Basic 2020. 12. 18. 11:51

    리스트 선언시 

     리스트변수명 = [ ]

     리스트변수명 = list( )

     리스트변수명 = [데이터1, 데이터2, 데이터3, ...]

    location = []
    location = list()

     

    리스트 추가시

     리스트변수명.append(데이터)  // 한개만 가능함

     리스트변수명.insert(데이터)

    location.append('인천시')
    location.insert('원주시')

     

    리스트 삭제시

     리스트변수명.remove(데이터)

     del 리스트변수명[인덱스번호]

    location.remove('경기도')
    del location[1]

     

    리스트 수정시

     리스트변수명[인덱스번호] = 수정할 데이터

    location[1] = '부산시'

     

    리스트 정열

    num_set = [8,5,9,4,6,1]
    num_set.sort()
    num_set

    역순 정렬

    num_set.reverse()
    num_set

    문자열 나누기

    python = "python is easy"
    String_list = python.split()

    'Python > Basic' 카테고리의 다른 글

    [Python_Basic]함수  (0) 2020.12.22
    [Python_Basic]반복문  (0) 2020.12.22
    [Python_Basic]조건문  (0) 2020.12.18
    [Python_Basic]문자열  (1) 2020.12.18
    [Python_Basic]데이터 출력, 입력  (0) 2020.12.18

    댓글

Designed by Tistory.