본문 바로가기
풀스택 개발일지

[웹개발 종합반 3주차] Python, 크롤링, mongoDB

by 노랑사랑팽이 2022. 10. 21.

🔖01. 설치

🔎 Python(Window) 다운로드

https://www.python.org/ftp/python/3.8.6/python-3.8.6-amd64.exe

 

🔎 gitbash 다운로드

https://git-scm.com/

 

Git

 

git-scm.com

 

🔖02. 연습 겸 복습

🔎 스파르타피디아 API(GET)

http://spartacodingclub.shop/web/api/movie

 

🔎 별점 이미지(별 반복찍기)

별 반복해서 찍기

javascript 내장함수 repeat 사용

let star_image = '⭐'.repeat(숫자)

 

🔎 로딩 되면 무비정보가져와 카드 붙이기

<script>
  $(document).ready(function () {
    listing();
  });

  function listing() {
    $('#cards-box').empty()
    $.ajax({
      type: "GET",
      url: "http://spartacodingclub.shop/web/api/movie",
      data: {},
      success: function (response) {
        let rows = response['movies']
        for(let i = 0; i < rows.length; i++){
          let title = rows[i]['title']
          let desc = rows[i]['desc']
          let star = rows[i]['star']
          let image = rows[i]['image']
          let comment = rows[i]['comment']

          let star_image = '⭐'.repeat(star)

          let temp_html = `<div class="col">
                              <div class="card">
                                <img src="${image}" class="card-img-top" alt="...">
                                <div class="card-body">
                                  <h5 class="card-title">${title}</h5>
                                  <p class="card-text">${desc}</p>
                                  <p>${star_image}</p>
                                  <p class="mycomment">${comment}</p>
                                </div>
                              </div>
                            </div>`

          $('#cards-box').append(temp_html)
        }
      }
    })
  }
</script>


🔖03. 파이썬 시작하기

🔎 python 파일 만들 때 설정

 

🔎 hello  출력

print('hello sparta!!')


🔖04. 파이썬 기초공부

🔎 변수 및 기본 연산

a = 2      # 2을 a에 넣는다
b = 2      

print(a+b)

 

🔎 List

a_list = ['사과', '귤', '배']
print(a_list[0])

a_list.append('감')
print(a_list)

 

🔎 Dictionary

a_dict = {'name':'bob','age':21}
print(a_dict['name'])

 

🔎 함수

def sum(a, b):
	return a+b
    
print(sum(1,2))

 

🔎 조건문

def is_adult(age):
    if age > 20:
        print('성인입니다')
    else:
        print('청소년입니다')

is_adult(15)

 

🔎 반복문

fruits = ['사과','배','배','감','수박','귤','딸기','사과','배','수박']

for fruit in fruits:
    print(fruit)

 

🔎 반복문 + 조건문

fruits = ['사과','배','배','감','수박','귤','딸기','사과','배','수박']

count = 0
for fruit in fruits:
    if fruit == '사과':
        count += 1

print(count)
people = [{'name': 'bob', 'age': 20},
          {'name': 'carry', 'age': 38},
          {'name': 'john', 'age': 7},
          {'name': 'smith', 'age': 17},
          {'name': 'ben', 'age': 27}]

for person in people:
    if person['age'] > 20:
        print(person['name'])

☀️ 느낀점

계속 강의를 이어가려니깐 너무 힘들다. 조금 쉬어야겠다.

파이썬을 실행하기 위해서는 인터프리터 설정이 정말정말 중요하다. 저번에 수강했을때도 인터프리터 설정이 잘못되어 뻘짓을 좀 했었다. 이런저런 오류들... 프로그램 돌리기 위해 설치할때도 환경설정이 중요하다. 안되면 어마어마한 시간이 낭비된다.ㅠ

댓글