본문 바로가기

IT/[파이썬]5

[파이썬] pickle 로 변수 저장하기 import pickle data = ['a','b','c'] # Save pickle with open("filename.pickle","wb") as fw: pickle.dump(data, fw) # Load pickle with open("filename.pickle","rb") as fr: data = pickle.load(fr) print(data) 2020. 11. 21.
[파이썬] 엑셀 파일 행, 열로 읽고 쓰기 import xlrd from xlutils.copy import copy for i in range(1, 7): # 엑셀파일 열기 wb = xlrd.open_workbook('파일이름.xlsx') sheet = wb.sheet_by_index(0) # 엑셀 하단에 위치한 시트탭 번호 # 검색할 키워드 가져오기 keyword = sheet.cell(i, 5).value # 헤더 읽어오는 부분 print(keyword) # 파일이름.xlsx를 복사하여 가져온다. copy_wb = copy(wb) copy_sheet = copy_wb.get_sheet(0) # 엑셀 하단에 위치한 시트탭 번호 # 복사본에 셀 추가 copy_sheet.write(행번호,열번호,'추가할 입력값') copy_sheet.write(.. 2020. 9. 16.
jupyter notebook 주피터 IOPub data rate exceeded. 해결방법 IOPub data rate exceeded. The notebook server will temporarily stop sending output to the client in order to avoid crashing it. To change this limit, set the config variable `--NotebookApp.iopub_data_rate_limit`. Current values: NotebookApp.iopub_data_rate_limit=1000000.0 (bytes/sec) NotebookApp.rate_limit_window=3.0 (secs) 출력 데이터 초과시 발생하는 오류이다. 해결방법 누르면 나타나는 cmd 창에 jupyter notebook --NotebookAp.. 2020. 6. 12.
크롤링 안되는 사이트 or 거부당할 때 크롤링 할 때 다른 주소는 requests.get(url) 을 받으면 페이지 소스를 잘 받아오는데, 아무 반응이 없거나 위에 그림 처럼 오류가 발생하는 페이지가 있다. 이 때, requests.get(url).text 를 이용해서 내용을 확인해 볼 수 있다. improt requests url = "크롤링할 사이트주소" html = requests.get(url).text html 사이트에서 거부당했음을 확인 할 수 있다. 서버에서 봇으로 인지하고 차단한 경우이다. 불법적인 크롤링을 막기 위한 조치로 해당 사이트에서 크롤링 한 데이터를 상업적인 목적으로 활용할 생각이라면, 여기서 그만두는 것을 추천한다. 서버에서 봇인지 사람인지 사용자를 구분해주는 값을 담는 그릇이 있다. headers 라는 그릇에 {'.. 2020. 4. 5.