라벨이 array인 게시물 표시

파이썬[Python]: array - pop 메서드

파이썬(Phthon): array 클래스 - pop 메서드(method) /// 설명 포지션 i에 해당하는 위치의 데이터를 삭제합니다. i가 음수일경우 마지막 위치에서 역행합니다. ※ 형식 array.pop(i) reference https://docs.python.org/3/library/array.html#module-array /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 from  array  import   *   test_array  =  array( 'u' , [ 'a' ,  'b' ,  'c' ,  'd' ,  'e' ,  'f' ])   for  i  in  test_array:      print (i, end = ' ' )   test_array.pop( 1 )   print ()   for  i  in  test_array:      print (i, end = ' ' )   test_array.pop( - 2 )   print ()   for  i  in  test_array:      print (i, end = ' ' ) Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: array - count 메서드

파이썬(Phthon): array 클래스 - count 메서드(method) /// 설명 배열의 요소 중 같은 요소의 개수를 확인합니다. ※ 형식 array.count(x) reference https://docs.python.org/3/library/array.html#module-array /// 예제 1 2 3 4 5 6 7 8 9 from  array  import   *   test_array1  =  array( 'I' , [ 11 ,  12 ,  13 ,  14 ,  15 ,  16 ,  11 ,  11 ])   print (test_array1.count( 11 ))   test_array2  =  array( 'u' , [ 'a' ,  'b' ,  'c' ,  'd' ,  'e' ,  'f' ,  'a' ])   print (test_array2.count( 'a' )) Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: array - tounicode 메서드

파이썬(Phthon): array 클래스 - tounicode 메서드(method) /// 설명 배열의 데이터를 유니코드 문자열로 변환합니다. ※ 형식 array.tounicode() reference https://docs.python.org/3/library/array.html#module-array /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 from  array  import   *   test_array  =  array( 'u' , [ 'a' ,  'b' ,  'c' ,  'd' ,  'e' ,  'f' ])   for  i  in  test_array:      print (i, end = ' ' )   print ()   array_to_unicode  =  test_array.tounicode()   print (array_to_unicode) Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: array - tolist 메서드

파이썬(Phthon): array 클래스 - tolist 메서드(method) /// 설명 배열의 데이터를 리스트로 변환합니다. ※ 형식 array.tolist() reference https://docs.python.org/3/library/array.html#module-array /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 from  array  import   *   test_array  =  array( 'u' , [ 'a' ,  'b' ,  'c' ,  'd' ,  'e' ,  'f' ])   for  i  in  test_array:      print (i, end = ' ' )   print ()   array_to_list  =  test_array.tolist()   print (array_to_list)   for  i  in  array_to_list:      print (i, end = ' ' ) Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: array - tobytes 메서드

파이썬(Phthon): array 클래스 - tobytes 메서드(method) /// 설명 배열의 데이터를 바이트 문자열로 변환합니다. ※ 형식 array.tobytes() reference https://docs.python.org/3/library/array.html#module-array /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 from  array  import   *   test_array  =  array( 'u' , [ 'a' ,  'b' ,  'c' ,  'd' ,  'e' ,  'f' ])   for  i  in  test_array:      print (i, end = ' ' )   print ()   array_to_bytes  =  test_array.tobytes()   print (array_to_bytes) Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: array - reverse 메서드

파이썬(Phthon): array 클래스 - reverse 메서드(method) /// 설명 원본 배열의 순서를 역순으로 변경합니다. ※ 형식 array.reverse() reference https://docs.python.org/3/library/array.html#module-array /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 from  array  import   *   test_array  =  array( 'u' , [ 'a' ,  'b' ,  'c' ,  'd' ,  'e' ,  'f' ])   for  i  in  test_array:      print (i, end = ' ' )   test_array.reverse()   print ()   for  i  in  test_array:      print (i, end = ' ' ) Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: array - remove 메서드

파이썬(Phthon): array 클래스 - remove 메서드(method) /// 설명 배열에서 처음으로 발견되는 값 x를 삭제합니다. ※ 배열에 해당하는 값이 없을 경우 오류가 발생합니다. ※ 형식 array.remove(x) reference https://docs.python.org/3/library/array.html#module-array /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 from  array  import   *   test_array  =  array( 'u' , [ 'a' ,  'b' ,  'c' ,  'd' ,  'e' ,  'f' ])   for  i  in  test_array:      print (i, end = ' ' )   test_array.remove( 'c' )   print ()   for  i  in  test_array:      print (i, end = ' ' ) Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: array - insert 메서드

파이썬(Phthon): array 클래스 - insert 메서드(method) /// 설명 포지션 i에 해당하는 위치에 새로운 데이터(x)를 입력합니다. i가 음수일경우 마지막 위치에서 역행합니다. ※ 형식 array.insert(i, x) reference https://docs.python.org/3/library/array.html#module-array /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 from  array  import   *   test_array  =  array( 'u' , [ 'a' ,  'b' ,  'c' ,  'd' ,  'e' ,  'f' ])   for  i  in  test_array:      print (i, end = ' ' )   test_array.insert( 1 ,  'y' )   print ()   for  i  in  test_array:      print (i, end = ' ' )   test_array.insert( - 1 ,  'z' )   print ()   for  i  in  test_array:      print (i, end = ' ' ) Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: array - index 메서드

파이썬(Phthon): array 클래스 - index 메서드(method) /// 설명 배열의 요소(x)가 발견되어지는 최초의 배열 인덱스를 확인합니다. ※ 형식 array.index(x) reference https://docs.python.org/3/library/array.html#module-array /// 예제 1 2 3 4 5 6 7 from  array  import   *   test_array1  =  array( 'I' , [ 11 ,  12 ,  13 ,  14 ,  15 ,  16 ]) test_array2  =  array( 'u' , [ 'a' ,  'b' ,  'c' ,  'd' ,  'e' ,  'f' ])   print (test_array1.index( 14 )) print (test_array2.index( 'e' )) cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: array - fromunicode 메서드

파이썬(Phthon): array 클래스 - fromunicode 메서드(method) /// 설명 문자열을 배열에 추가합니다. ※ 추가하는 객체는 원본 배열의 형식과 같아야 합니다. ※ 형식 array.fromunicode(string) reference https://docs.python.org/3/library/array.html#module-array /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 from  array  import   *   test_array  =  array( 'u' ,  'I AM' ) test_str  =   ' A KOREAN'   print ( 'original: ' , end = '' ) for  i  in  test_array:      print (i, end = '' )   print ( '\n' )   print ( 'append:  ' , test_str)   print ()   test_array.fromunicode(test_str)   print ( 'appended: ' , end = '' ) for  i  in  test_array:      print (i, end = ' ' ) cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: array - fromlist 메서드

파이썬(Phthon): array 클래스 - fromlist 메서드(method) /// 설명 리스트를 배열에 추가합니다. ※ 추가하는 객체는 원본 배열의 형식과 같아야 합니다. ※ 형식 array.fromlist(list) reference https://docs.python.org/3/library/array.html#module-array /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 from  array  import   *   test_array  =  array( 'I' , [ 11 ,  12 ,  13 ,  14 ,  15 ,  16 ]) test_list  =  [ 17 ,  18 ,  19 ,  20 ,  21 ,  22 ]   for  i  in  test_array:      print (i, end = ' ' )   test_array.fromlist(test_list)   print ()   for  i  in  test_array:      print (i, end = ' ' ) cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: array - frombytes 메서드

파이썬(Phthon): array 클래스 - frombytes 메서드(method) /// 설명 문자열(바이트 문자열)을 배열에 추가합니다. ※ 추가하는 객체는 원본 배열의 형식과 같아야 합니다. ※ 바이트 문자열이 아닌 문자열을 입력하면 오류가 발생합니다. ※ 파이썬 배열은 2 Bytes 유니코드 문자를 사용합니다.(인코딩: utf-16, utf-16-le, utf-16-be) ※ 형식 array.frombytes(bytes) reference https://docs.python.org/3/library/array.html#module-array /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 from  array  import   *   test_array  =  array( 'u' ,  'I AM' ) test_str  =   ' A KOREAN' test_bytes  =  bytes(test_str,  'utf-16-le' ) # test_bytes = test_str.encode('utf-16-le')   print ( 'original: ' , end = '' ) for  i  in  test_array:      print (i, end = '' )   print ( '\n' )   print ( 'append:  ' , test_str) print ( 'bytes:   ' , test_bytes)   print ()   test_array.frombytes(test_bytes)   print ( 'appended: ' , end = '' ) for  i  in  test_array:      print (i, end = ' ' ) cs

파이썬[Python]: array - extend 메서드

파이썬(Phthon): array 클래스 - extend 메서드(method) /// 설명 생성된 배열의 마지막에 반복 가능한 객체(iterable)를 추가합니다. ※ 추가하는 객체는 원본 배열의 형식과 같아야 합니다. ※ 형식 array.extend(iterable) reference https://docs.python.org/3/library/array.html#module-array /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 from  array  import   *   test_array1  =  array( 'I' , [ 11 ,  12 ,  13 ,  14 ,  15 ,  16 ])   for  i  in  test_array1:      print (i, end = ' ' )   print ()   test_array2  =  array( 'I' , [ 17 ,  18 ,  19 ,  20 ,  21 ,  22 ])   test_array1.extend(test_array2)   for  i  in  test_array1:      print (i, end = ' ' ) cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: array - buffer_info 메서드

파이썬(Phthon): array 클래스 - buffer_info 메서드(method) /// 설명 배열이 사용하고 있는 메모리의 현재 주소와 요소의 길이(배열 요소의 수)를 확인합니다. ※ 형식 array.buffer_info() reference https://docs.python.org/3/library/array.html#module-array /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 from  array  import   *   test_array  =  array( 'I' , [ 11 ,  12 ,  13 ,  14 ,  15 ,  16 ])   print ( '    address   length' ) print (test_array.buffer_info()) print ( '\n' )   total_bytes  =  test_array.buffer_info()[ 1 ]  *  test_array.itemsize   print ( 'total_bytes: ' , end = '' ) print (test_array.buffer_info()[ 1 ],  '* ' , end = '' ) print (test_array.itemsize,  '= ' , end = '' ) print (total_bytes,  'Byte(s)' ) Colored by Color Scripter cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: array - append 메서드

파이썬(Phthon): array 클래스 - append 메서드(method) /// 설명 생성된 배열의 마지막에 값을 추가합니다. ※ 형식 array.append(x) reference https://docs.python.org/3/library/array.html#module-array /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 from  array  import   *   test_array  =  array( 'I' , [ 11 ,  12 ,  13 ,  14 ,  15 ,  16 ])   for  i  in  test_array:      print (i, end = ' ' )   print ()   test_array.append( 17 )   for  i  in  test_array:      print (i, end = ' ' ) cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: array - itemsize 변수

파이썬(Phthon): array 클래스 - itemsize 변수 /// 설명 배열에서 한 요소의 길이를 확인합니다. = 데이터 형식의 바이트 수 ※ 형식 array.itemsize reference https://docs.python.org/3/library/array.html#module-array /// 예제 1 2 3 4 5 from  array  import   *   test_array  =  array( 'I' , [ 11 ,  12 ,  13 ,  14 ,  15 ,  16 ])   print (test_array.itemsize,  'Byte(s)' ) cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: array - typecode 변수

파이썬(Phthon): array 클래스 - typecode 변수 /// 설명 생성된 배열의 형식을 확인합니다. ※ 형식 array.typecode reference https://docs.python.org/3/library/array.html#module-array /// 예제 1 2 3 4 5 from  array  import   *   test_array  =  array( 'I' , [ 11 ,  12 ,  13 ,  14 ,  15 ,  16 ])   print (test_array.typecode) cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –

파이썬[Python]: array - typecodes 변수

파이썬(Phthon): array 모듈 typecodes 변수(variable) /// 설명 가능한 모든 형식의 문자열을 확인합니다. ※ 형식 array.typecodes reference https://docs.python.org/3/library/array.html#module-array /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 from  array  import   *   print (typecodes)   # Type code   C Type           Python Type    Minimum size in bytes # 'b'         signed char         int                 1 # 'B'         unsigned char       int                 1 # 'u'         wchar_t             Unicode             2 #                                 (character) # 'h'         signed short        int                 2 # 'H'         unsigned short      int                 2 # 'i'         signed int          int                 2 # 'I'         unsigned int        int                 2 # 'l'         signed long         int                 4 # 'L'         unsigned long       int                 4 # 'q'         signed lon

파이썬[Python]: array - array 클래스

파이썬(Phthon): array 클래스(class) /// 설명 배열을 표현할 수 있는 객체를 정의합니다.(형식에 의해 제한되는 것을 제외하고는 리스트와 비슷합니다.) 예) 문자열, 정수, 실수 ※ 형식 array.array(typecode, [initializer]) reference https://docs.python.org/3/library/array.html#module-array /// 예제 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 from  array  import   *   # array # test_array = array('I') test_array  =  array( 'I' , [ 11 ,  12 ,  13 ,  14 ,  15 ,  16 ])   for  i  in  test_array:      print (i)   print ()   # list test_list  =  [ 17 ,  18 ,  19 ,  20 ,  21 ,  22 ]   for  i  in  test_list:      print (i, end = ' ' ) cs * 실행환경: Microsoft Windows 10 Homes * 인터프리터: 파이썬(Python 3.9) – 당신을 응원합니다. –