import re
li=[" ","1","12","123","1234","abc","1a"]
for string in li:
print(re.sub(r"[0-9]?", "A",string), end=" ")
-> A A AA AAA AAAA AAAAA AaAbAcA AAaA
import numpy as np
a = np.arange(1,101).reshape((10, 10))
a[[4, 4, 7,7 ], [3,5,3,5]]
->array([44, 46, 74, 76])
#(2)
import numpy as np
x = np.arange(1, 101).reshape(10, 10)
x[4::3, 3:6:2]
-> array([[44, 46],
[74, 76]])
#기타 문제
import numpy as np
a = np.arange(1, 101).reshape(10, 10)
a[[0,1,2,3 ], [6,7,8,9]]
-> array([ 7, 18, 29, 40])
#9.16 191번 문제
data = '''
<head>
<title>hello world</title>
</head>
'''
p = re.compile("(?<=>).+(?=<)")
p.findall(data)
-> ['hello world']
#4
#1~35로 구성된 6*6빙고판을 만들고 짝수만 출력하시오
a = np.arange(36).reshape(6,6)
a[:, 0::2]
- 1
- 1
- a[0:6][-7:-1]
- key.replace(':',"#")
- a["grape"]="포도"
del=- 8.10
divomo
11
12 오버라이징 ->3
13 -> 2
15 ->ㄴ,ㄷ,ㄱ
16
17
np.linspace(1,10,10)
-> array([ 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.])
np.linspace(1,9,5)
-> array([1., 3., 5., 7., 9.])
np.arange()
np.linspace() {48,107}
np.ones(){49,112}
np.zeros(){113]
a=[1,2,3,4]
(1)b=a,(view)
(2)c=a.copy()
(3)import copy
d=copy.copy()
: stack 이란 : FIFO . 선착순의 반대
a = np.arange(6)
array = a.copy()
for i in range(5):
i+=1
array = np.vstack((array, a+10*i))
a=array
a
a = np.arange(25).reshape(5,5)
a
출처:
https://rfriend.tistory.com/ -> ppt 참고 자료
https://datascienceschool.net/01%20python/03.01%20%EB%84%98%ED%8C%8C%EC%9D%B4%20%EB%B0%B0%EC%97%B4.html -> array