목록파이썬 (16)
Head vs breakz
1.heapq - heappush,heappop,heapushpop,heapify import heapq a= [] heapq.heappush(a,4) heapq.heappush(a,2) heapq.heappush(a,3) heapq.heappush(a,5) print(a) #[2, 4, 3, 5] heapq.heappop(a) print(a) #[3, 4, 5] heapq.heappushpop(a,7) print(a) #[4, 7, 5] b = [4, 1, 7, 3, 8, 5] heapq.heapify(b) print(b) #[1, 3, 5, 4, 8, 7] 2.deque - append,appendleft,pop,popleft,extend,extendleft,rotate from collections..
1. 가상환경 만들고 시작 conda creat -n 가상환경이름 conda activate 가상환경이름 2. 가상환경에 설치 conda install numpy conda install pillow conda install opencv conda install scipy conda install cmake conda install -c conda-forge dlib conda install -c akode face_recognition_models #위에코드가 안되면 pip install --no-dependencies face_recognition
def solution(msg): word_list =['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'] status = True total = True count = 0 val_count = 0 answer = [] for i in range(len(msg)): for j in range(len(msg),0,-1): if msg[i:j] in word_list and status ==True : answer.append(word_list.index(msg[i:j])+1) word_list.append(msg[i:j+1]) count += j-i if j-i > 1: ..
#튜플 def solution(s): b = [] a = list(s[2:-2].split("},{")) a.sort(key = len) for i in range(len(a)): c=list(a[i].split(",")) for j in range(len(c)): if c[j] not in b : b.append(c[j]) for q in range(len(b)): b[q] = int(b[q]) answer = b return answer 문자열을 쪼개고, 다시 리스트로 쪼개고, 문자가 없으면 넣어주고 문자를 숫자로 변환