Beautiful Soup 모듈 공식 홈페이지
https://www.crummy.com/software/BeautifulSoup/bs4/doc/
pip install beautifulsoup4
# 모듈을 읽어들입니다.
from urllib import request
from bs4 import BeautifulSoup
# urlopen() 함수로 기상청의 전국 날씨 읽어보기
target = request.urlopen("http://www.kma.go.kr/weather/forecast/mid-term-rss3.jsp?stnId=108")
# BeautifulSoup을 사용해 웹 페이지 분석하기
soup = BeautifulSoup(target, "html.parser")
# location 태그 찾기
for location in soup.select("location"):
    # 구분, 도시, 날씨, 최저*최고 기온, 일자 출력
    print("구분: ", location.select_one("province").string)
    print("도시: ", location.select_one("city").string)
    print("날씨: ", location.select_one("wf").string)
    print("최저 기온: ", location.select_one("tmn").string)
    print("최고 기온: ", location.select_one("tmx").string)
    print("일자: ", location.select_one("tmEf").string)
    print()
pip install flask
python 환경변수 설정이 되어있는 지 확인한다

python 입력했을 때 아래 사진과 같이 뜨면 성공!
이 후 실행 코드 입력하기
  set FLASK_APP=파일명.py
  flask run
Command Prompt로 변경 후 똑같이 코드 입력  set FLASK_APP=파일명.py
  flask run

from flask import Flask
app = Flask(__name__)
# 데코레이터(decorator)
@app.route("/")
def hello():
    return "<h1>Hello World!</h1>"
app.run()app.run()은 없는 코드임..app.run() 추가 후 Ctrl + F5로 실행함.
# 모듈 읽기
from flask import Flask
from urllib import request
from bs4 import BeautifulSoup
# 웹 서버 생성 & route 설정
app = Flask(__name__)
@app.route("/")
def hello():
    # urlopen() 함수로 기상청의 전국 날씨 읽기
    target = request.urlopen("http://www.kma.go.kr/weather/forecast/mid-term-rss3.jsp?stnId=108")
    # BeautifulSoup을 사용해 웹 페이지 분석하기
    soup = BeautifulSoup(target, "html.parser")
    # location 태그 찾기
    # output 변수 선언
    output = ""
    for location in soup.select("location"):
        # 내부의 province, city, wf, tmn, tmx 태그를 찾아 출력
        # 지역 구분을 h3로, 각 도시들은 h4로 나타냄
        # 날씨, 최저, 최고기온을 표시해주고 hr(줄)을 이용하여 다음 출력 내용과 구분
        output += "<div style='width: 30%;background: #eee;padding-left: 30px;'>"
        output += "<h3>{}</h3>".format(location.select_one("province").string)
        output += "<h4>{}</h4>".format(location.select_one("city").string)
        output += "날씨: {}<br/>".format(location.select_one("wf").string)
        output += "최저/최고 기온: {}/ {}"\
            .format(\
                location.select_one("tmn").string,\
                location.select_one("tmx").string\
            )
        output += "</div>"
        output += "<hr/>"
    return output
app.run()beautiful_weather.py와 flask_basic.py 코드를 합한 것과 다름없다.최저/최고 기온을 구하는 부분인 듯 하다.output += "최저/최고 기온: {}/ {}"\ .format(\ location.select_one("tmn").string,\ location.select_one("tmx").string\ )
- 최저/최고 기온 뒤에 보이는 {}에 각각의 결과값이 들어가게 된다.
\를 사용하여 임의로 줄을 띌 때마다('Enter를 칠 때마다') 구분을 해준 것 같다..

예시
__init__ 생성자
class 클래스명:
	def __init__(self, 추가 매개변수):
    	passclass 클래스명:
	def 메소드명(self, 추가 매개변수):
    	pass클래스 내부에 Method 선언하기
# 클래스 선언
class Student:
    def __init__(self, name, age):
        self.name = name
        self.age = age
    def s_name(self):
        return "{}".format(self.name)
    
    def s_age(self):
        return "{}".format(self.age)
    def to_string(self):
        return "{}\t{}".format(self.s_name(), self.s_age())
    
# 학생 리스트 선언
students = [
    Student("Hon", 20),
    Student("Gong", 24),
    Student("Python", 30)
]
# 학생의 이름을 한 명씩 나타냅니다.
print("이름\t나이")
for student in students:
    # 출력
    print(student.to_string())
    