작업/데이터분석(8)
-
21.12.02 JSON, CSV
실습2 # 사용자가 시청한 작품의 리스트를 저장합니다. 수정하지 마세요. user_to_titles = { 1: [271, 318, 491], 2: [318, 19, 2980, 475], 3: [475], 4: [271, 318, 491, 2980, 19, 318, 475], 5: [882, 91, 2980, 557, 35], } def get_user_to_num_titles(user_to_titles): user_to_num_titles = {} # 아래 함수를 완성하세요. for user,titles in user_to_titles.items(): # .items는 딕셔너리의 키와 벨류를 꺼내오는 듯? # print(user) 1 # print(titles) [271,318,491] user_to_..
2021.12.04 -
21.12.01 파이썬 파일 다루기 / 데이터 구조 다루기 / 그래프 다루기
파일 다루기 # 1. file = open('data.txt') content = file.read() file.close() # 2. with open('data.txt') as file: content = file.read() # file.close()가 필요없다. # 3. 파일의 모드 with open('data.txt', 'w') as file: # 읽기 모드 file.write('Hello') 한 줄씩 읽어와서 배열에 담기 contents = [] with open('data.txt') as file: for line in file: content.append(line) # 텍스트 파일을 불러옵니다. filename = 'corpus.txt' def print_lines(filename): # ..
2021.12.01