๋ถ๋ฅ ์ ์ฒด๋ณด๊ธฐ243 (23.02.09.)Python ํ๋ก๊ทธ๋๋ฐ: Web Crawling, Web Scraping, BeautifulSoup Web crawling ํฌ๋กค๋ง(Crawling)์ด๋ ์ฌ์ ์ ์๋ฏธ๋ก ๊ธฐ์ด๋ค๋๋ค๋ฅผ ๋ปํ๊ณ , Web์์๋ ๋์๋ค๋๋ฉด์ ์ํ๋ ์ ๋ณด๋ฅผ ์์งํ๋ ํ์๋ฅผ ์๋ฏธํ๋ค. ํฌ๋กค๋ง์ ๋์์ ์์์ ์ธ๊ธํ ๋๋ก ์น ์์ ์กด์ฌํ๋ ์ ๋ณด๋ค์ด๋ฉฐ, ํด๋น ์ ๋ณด๋ ๋ค์ํ ํํ๋ก ์กด์ฌํ ์ ์๋ค.(์ด๋ฏธ์ง, ํ ์คํธ, API ๋ฑ) ํฌ๋กค๋ง์ ํฌ๊ฒ ๋ ๊ฐ์ง๋ก ๋๋์ด ์ง ์ ์๋ค. (์ ์ ํฌ๋กค๋ง VS ๋์ ํฌ๋กค๋ง) ์ ์ ํฌ๋กค๋ง ํน๋ณํ ์ ์ฐจ ์์ด ํน์ URL์ ํตํด ๋ฐ์ดํฐ ์์ง ๊ฐ๋ฅ ์๋ก๊ณ ์นจํ์ง ์์ผ๋ฉด ํ์ด์ง ์์ ๋ฐ์ดํฐ๋ ๋ณํ์ง ์๋๋ค. ์๋๊ฐ ๋น ๋ฅด๋ค. ์์ง ๋์์ ํ๊ณ ์กด์ฌํ๋ค. ์ฌ์ฉ ๊ฐ๋ฅ ๋ผ์ด๋ธ๋ฌ๋ฆฌ : requests โ ๋์ ํฌ๋กค๋ง ํน๋ณํ ์ ์ฐจ ์์ด ํน์ URL์ ํตํด ๋ฐ์ดํฐ ์์ง ๋ถ๊ฐ๋ฅ(๋ค์ด๋ฒ ๋ฉ์ผ์ ๊ฒฝ์ฐ) ์๋๊ฐ ๋๋ฆฌ๋ค. ์์ง ๋์์ ํ.. Python programming 2023. 2. 14. (23.02.08)Python ํ๋ก๊ทธ๋๋ฐ : Pickle ๋ชจ๋์ ์ฌ์ฉํ ์ง๋ ฌํ(Serialization), ์์ธ์ฒ๋ฆฌ pickle ๋ชจ๋์ ์ฌ์ฉํ ์ง๋ ฌํ(Serialization) ์ง๋ ฌํ : pickle.dump(data,fout) ์ญ์ง๋ ฌํ : pickle.load(fin) ์ง๋ ฌํ๋ฅผ ์ด์ฉํ CRUD Emp ํด๋์ค ๋ฆฌ์คํธ์ Emp๊ฐ์ฒด๋ฅผ ์ ์ฅํ๊ณ ๋ฆฌ์คํธ๋ฅผ ์ง๋ ฌํ # Emp (id, name, dept, phone) # ์ถ๊ฐ(a), ๋ชฉ๋ก(s), ๊ฒ์(f), ์์ (u), ์ญ์ (d), ์ข ๋ฃ(x) 1 2 3 4 5 6 7 8 9 10 11 12 13 import pickle class Emp: def __init__(self, id=None, name=None, dept=None, phone=None): self.id = id self.name = name self.dept = dept self.phone = phone def __.. Python programming 2023. 2. 14. (23.02.07.)Python ํ๋ก๊ทธ๋๋ฐ : ํ์ด์ฌ ์ ๊ทผ ์ ์ด์ (Access modifier) , ์ฐ์ฐ์ ์ค๋ฒ๋ผ์ด๋ , ํ์ผ ์คํธ๋ฆผ ํด๋์ค์ ๊ฐ์ฒด ์๋ฐ์ Access modifier(์ ๊ทผ ์ ์ด์) : public, private, protected ํ์ด์ฌ์์ ์ด๋ฌํ ์ฉ์ด๋ ์์ง๋ง ๊ฐ๋ ์ ์กด์ฌํ๋ค. _ ํ๋ ์ง๋ฆฌ๋ ์๋ฐ์์ protected์ ๊ฐ์ ๊ฐ๋ ์ด๋ค. __ ๋ ํด๋์ค ๋ฐ์์ ์ด๊ธฐํ๊ฐ ๋ถ๊ฐ๋ฅ ํ๋ค. ์๋ฐ์์ private ๊ฐ๋ ์ด๋ค. ํด๋์ ๋ด์์ ์์ฑ์ ์ ๊ทผ ํด์ฃผ๊ธฐ์ํด @property annotation ์ ์ฌ์ฉํ๋ค. In[24]์์ name ๋ณ์์ ์ง์ ์ ์ผ๋ก ๊ฐ์ ์ฃผ๋ ๊ฒ๊ฐ์ง๋ง setter ๋ฉ์๋๊ฐ ํธ์ถ๋ ๊ฒ์ด๋ค. ํ์ด์ฌ์์ ์์ is a ๊ด๊ณ์ด๊ธฐ ๋๋ฌธ์ ์์์ ํด์ฃผ๋๋ฐ ์๋ฐ์์ ์ฒ๋ผ extend ํด์ฃผ๋ ๊ฒ์ด ์๋๋ผ () ์์ ํด๋์ค๋ช ์ ๋ฃ์ด์ฃผ๋ฉด๋๋ค. ์ฐ์ฐ์ ์ค๋ฒ๋ผ์ด๋ ํ ์คํธ ํ์ผ ๊ธฐ๋ฐ ์ฌ์์ ๋ณด CRUD # ํ์ผ์ ์ด์ด์ฐ๊ธฐ :.. Python programming 2023. 2. 7. (23.02.06.)Python ํ๋ก๊ทธ๋๋ฐ : module sys , ํ์ด์ฌ Class ์ ๊ฐ์ฒด # ํ์ฌ ํ์ด์ฌ์ด ์คํ๋๋ ์ปดํจํฐ > ํธ์คํธ ์ปดํจํฐ import os windows NT ์ปค๋์ด ๋ ๋ง์ ๊ธฐ๋ฅ์ด ์๋๋ฐ ๋์ค์ ๊ฐ์ธ ํผ์จ์๋ windows NT๊ฐ ์ด์์ฒด์ ๋ก ์ฐ์ด๊ฒ๋๋ค. Python programming 2023. 2. 7. (23.02.03)Python ํ๋ก๊ทธ๋๋ฐ: ํ์ด์ฌ ํจ์ ์ค์ต Python programming 2023. 2. 6. (23.02.02.)Python ํ๋ก๊ทธ๋๋ฐ: ํ์ด์ฌ Set(์งํฉ) ๋ค๋ฃจ๊ธฐ & ํ์ด์ฌ ์ฐ์ฐ์ Set(์งํฉ) ์ฐ์ฐ์ Python programming 2023. 2. 6. (23.02.01.)Python ํ๋ก๊ทธ๋๋ฐ : Tuple(ํํ) & Dictionary(๋์ ๋๋ฆฌ) Tuple Dictionary List - Dictionary ๊ตฌ์กฐ๋ฅผ ์ด์ฉํ ์ฌ์๊ด๋ฆฌ ํ๋ก๊ทธ๋จ CRUD 1 2 3 4 def show_menu(): menu = input("๋ชฉ๋ก(s), ์ถ๊ฐ(a), ๊ฒ์(f), ์์ (u), ์ญ์ (d), ์ข ๋ฃ(x)") menu = menu.strip() return menu Colored by Color Scripter cs 1 2 3 4 5 6 7 8 9 10 11 def add(): str_emp = input("๋ฒํธ,์ด๋ฆ,ํธ๋ํฐ๋ฒํธ ์ ๋ ฅ: ").strip() cnt = len(str_emp.split()) if cnt Python programming 2023. 2. 6. (23.01.31)Python ํ๋ก๊ทธ๋๋ฐ : ํ์ด์ฌ List ์๋ฃํ (list ์ ํจ์๋ค) List๋ฅผ ํ์ฉํ ์ฌ์ ์ ๋ณด CRUD โโํ์ด์ฌ List ์๋ฃํโโ '__add__', '__class__', '__class_getitem__', '__contains__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '_.. Python programming 2023. 1. 31. (23.01.30.)Python ํ๋ก๊ทธ๋๋ฐ : Anaconda ์ค์น์ Jupiter Notebook ์ฌ์ฉํ์ฌ ํ์ด์ฌ ์๋ฃํ ๊ณต๋ถ Python - Machine Learning - AI Application - ๋ฐ์ดํฐ ์ ์ฒ๋ฆฌ - Spring(Web ์๋ฒ) Flask(AI ์๋ฒ ์ญํ ์ ํ๋๋ก) ์ค์น - Python ๋ง ์ค์น ํ๊ฒ๋๋ฉด ์ธ์ด์ ๋ด์ฅ๋ ๊ธฐ๋ณธ ๋ชจ๋๋ง ํฌํจ๋๋ค. - Anaconda Distritution ์๋์ฝ๋ค ๋ฐฐํฌํ์ ๊ธฐ๋ณธ ๋ชจ๋์ ๋ ๋ง์ ๊ธฐ๋ฅ์ ๋ชจ๋๊น์ง ํฌํจํ๊ณ ์๋ค. ์๋ํฐ๋ ๋ค์ด์๋ค.(Python, ML modules, IDE(์ฅฌํผํฐ ๋ ธํธ๋ถ)) CLI(Command Line Interface) - cmd, shell -python shell : ์ํธ ๋ํ์ ์ด๋ค.(Interactive shell) Anaconda Distritution๋ฅผ ์ค์น ํ ์๋์ฝ๋ค ํ๋กฌํํธ๋ฅผ ์คํํด ์ค๋ค. ์๋์ฝ๋ค ํ๋กฌํํธ์ ์ฅฌํผํฐ ๋ ธํธ๋ถ์์ ๋ง.. Python programming 2023. 1. 30. (23.01.27)์ดํด๋ฆฝ์ค์์ ์์ฑํ ํ๋ก์ ํธ๋ฅผ ์ด์์๋ฒ์ ๋ฐฐํฌํ๊ธฐ , ์ดํด๋ฆฝ์ค ๋ฆฌ์กํธ ์ฐ๋ํ๊ธฐ (Eclipse - React) ์ดํด๋ฆฝ์ค์์ ์์ฑํ ํ๋ก์ ํธ๋ฅผ ์ด์์๋ฒ์ ๋ฐฐํฌํ๊ธฐ Eclipse๋ ๊ฐ๋ฐ ํ๊ฒฝ, ๊ฐ๋ฐ ํ ์คํ ํ๊ฒฝ์ ๋ฐฐํฌํ๋ ์ ์ฐจ๊ฐ ์๊ตฌ๋จ ์คํ ํ๊ฒฝ: Tomcat ์๋ ๊ฒฝ์ฐ Tomcat ์๋ ๊ฒฝ์ฐ JAR ํ์ผ๋ก ํจํค์ง : Web App ์๋๊ฒฝ์ฐ ( ex. ojdbc ๋ฑ๋ฑ), Tomcat ์ด ๋ด์ฅ๋ Web App ์ธ ๊ฒฝ์ฐ java -jar myproject.jar application.properties์์ war๋ฅผ jar๋ก ๋ฐ๊ฟ์ฃผ๊ธฐ WAR ํ์ผ๋ก ํจํค์ง : Web Application Archives, Tomcat์ webapps/์์ ๋ณต์ฌ ์์๋ฅผ ๋ณด๊ธฐ ์ํ ํ๋ก์ ํธ๋ฅผ ์์ฑํ๊ธฐ application.properties ์ค์ ํ ์คํธ์ฉ ์ปจํธ๋กค๋ฌ ๋ง๋ค๊ธฐ ์ปจํธ๋กค์ด ์ ์๋ํ๋์ง ํ ์คํธ clean ํด์ฃผ๊ธฐ install ํด์ฃผ๊ธฐ .. Web programming 2023. 1. 28. (23.01.26.) React ํ๋ ์์ํฌ : ๋ฆฌ์กํธ์์ JSON ํ์ผ ๋ค๋ฃจ๊ธฐ ๋ฐ ํํฐ๊ธฐ๋ฅ ๋ฆฌ์กํธ์์ JSON ํ์ผ ๋ค๋ฃจ๊ธฐ List.js 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 import emps from "./emps.json"; function List() { return( ํ ์ด๋ธ์ ๋ฐ์ดํฐ ํ์ํ๊ธฐ ๋ฒํธ์ด๋ฆ์ ํ { emps.list.map((emp)=> {emp.num}{emp.name}{emp.phone} ) } ); } export default List; //emps ์ ์ด์จ ์ด๋ ์ด emp๋ ๋ฆฌ์คํธ์ ํ๋์ ์์(์ต๋ช ํจ์์ ํ๋ผ๋ฏธํฐ) Colored by Color Scripter cs 1. jsx์์ ํ ์ด๋ธ์ ํค๋์ ๋ฐ๋๊ฐ ๊ผญ์์ด์ผ ํ๋ค. 2. return๋ฌธ์ฅ ์์์๋ 1๊ฐ์ ํ๊ทธ๋ง ์ฌ์ฉํ ์ ์๋ค... Framework/React Framework 2023. 1. 28. (23.01.25)React ํ๋ ์์ํฌ : ๋ฆฌ์กํธ ๋ฐฐ์ด ๋ค๋ฃจ๊ธฐ ๋ฆฌ์กํธ ๋ฐฐ์ด ๋ค๋ฃจ๊ธฐ Component ์ ์ธ, ์ฌ์ฌ์ฉ ์์คํ ์ํํธ์จ์ด - ์ด์์ฒด์ ๋ฅผ ๋ง๋ค๊ฑฐ๋ ํ๋.... SPA(Single Page Application) - ์์ฉ ํ๋ก๊ทธ๋จ์ ๋ง๋ค๊ฑฐ๋ ํ๋....(๋ฆฌ์กํธ๋ ์ฌ๊ธฐ์ ํด๋น) ๋น ๋ฅธ ํน์ง์ด ์๋ค. ๋ฐ์ดํฐ ๋น์ฉ ์ ๊ฐ ํด๋ฆญํ๋ฉด ์๋ฒ์ ๋ํ ์์ฒญ์ด ์๋๋ผ ์ปดํฌ๋ํธ๋ง ๋ฐ๋๊ฒ๋ ์๋ฒ์ธก ๋ฐ์ดํฐ๋ฅผ ์ฉ์ฒญํ ๋๋ ajax ์ฌ์ฉ ๋ฐฐ์ด ๋ค๋ฃจ๊ธฐ -๋ก์ปฌ์ ์ ์ธ๋ ๋ฐฐ์ด -back end ์์ ์ ๋ฌํ ๋ฐฐ์ด (๋ฆฌ์คํธ) 1 2 3 4 5 list.map(f); *f๋ list ์ ์์ ๊ฐ๊ฐ์ ๋ฐ์์ ๊ฐ๊ณตํ๊ณ ๋ค์ ๋ฐฐ์ด๋ก ๋ฆฌํด (v) => {v} list.map( (v) => {v} ) Colored by Color Scripter cs -list.map(f); /* f๋ list์ ์์ ๊ฐ.. Framework/React Framework 2023. 1. 25. ์ด์ 1 ยทยทยท 9 10 11 12 13 14 15 ยทยทยท 21 ๋ค์