<NAVER boostcourse>
에서 수강한 강의를 바탕으로 정리한 내용입니다.: Comma Seperate Value
(basic)
.split(',')
로 데이터를 구분해줌❗ text 파일 형태로 데이터 처리 시 문장 내 comma에 대한 전처리 과정이 필요함
▶ 간단한 csv 파일 처리를 위한 python에서 csv 객체를 제공함
'
사용❗ csv 파일은 해당 방법으로 다룰 수 있지만 판다스라는 아주 편리한 라이브러리로 쉽게 다룰 수 있음
: World Wide Web
- 요청 : 웹주소, Form, Header 등 (클라이언트 → 서버)
- 처리 : Database 처리 등 요청에 대응 (서버)
- 응답 : HTML, XML 등으로 결과 반환 (서버 → 클라이언트)
- 렌더링 : HTML, XML 표시 (클라이언트)
: 웹 상의 정보를 구조적으로 표현하기 위한 언어
: 복잡한 문자열 패턴을 정의하는 문자 표현 공식
import re
import urllib.request # url로부터 데이터를 받아오는 라이브러리
url = 'url'
html = urllib.request.urlopen(url)
html_contents = str(html.read())
id_results = re.findall(r"([A-Za-z0-9]+\*\*\*)", html_contents)
# html source 내에 있는 id를 모두 출력
for result in id_results:
print(results)
: eXtensible Markup Language
! conda install -c anaconda beautifulsoup4
from bs4 import BeautifulSoup # 모듈 호출
soup = BeautifulSoup(books_xml, "lxml") # 객체 생성
soup.find_all("author") # 서치 함수로 tag 찾음
: JavaScript Object Notation
import json
# json read
with open("json_example.json", "r", encoding="utf8") as f:
contents = f.read()
json_data = json.loads(contents)
print(json_data["employee"]
# json write
json_data = {'Name':'Zara', 'Age':7, 'Class':'First'}
with open("data.json", "w") as f:
json.dump(dict_data, f)