1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | import numpy as np m = np.array([[ 0, 1, 2, 3, 4], [ 5, 6, 7, 8, 9], [10, 11, 12, 13, 14]]) # ÀÌ Çà·Ä¿¡¼ °ª 7 À» À妽ÌÇÑ´Ù. print("¸®½ºÆ® ¹æ½Ä:",m[1][2],"numpy ¹æ½Ä:",m[1,2]) # ÀÌ Çà·Ä¿¡¼ °ª 14 À» À妽ÌÇÑ´Ù. print("¸®½ºÆ® ¹æ½Ä:",m[2][4],"numpy ¹æ½Ä:",m[2,4]) # ÀÌ Çà·Ä¿¡¼ ¹è¿ [6, 7] À» ½½¶óÀ̽ÌÇÑ´Ù. print("¸®½ºÆ® ¹æ½Ä:",m[1][1:3],"numpy ¹æ½Ä:",m[1,1:3]) # ÀÌ Çà·Ä¿¡¼ ¹è¿ [7, 12] À» ½½¶óÀ̽ÌÇÑ´Ù. print("¸®½ºÆ® ¹æ½Ä:","¿¹æÇâ ½½¶óÀÌ½Ì ºÒ°¡´É","numpy ¹æ½Ä:",m[1:3,2]) # ÀÌ Çà·Ä¿¡¼ ¹è¿ [[3, 4], [8, 9]] À» ½½¶óÀ̽ÌÇÑ´Ù. print("¸®½ºÆ® ¹æ½Ä:","¿¹æÇâ ½½¶óÀÌ½Ì ºÒ°¡´É","numpy ¹æ½Ä:",m[0:2,3:5]) # ÀÌ Çà·Ä¿¡¼ ¹è¿ [[1, 3], [11, 13]] À» ½½¶óÀ̽ÌÇÑ´Ù. print("¸®½ºÆ® ¹æ½Ä:","¿¹æÇâ ½½¶óÀÌ½Ì ºÒ°¡´É","numpy?¹æ½Ä:",m[0::2,1::2]) | cs |