python (9) 썸네일형 리스트형 [PYTHON] __mro__ 컴퓨터가 이해하는 객체 우선순위를 파악하는 함수 class C1(): def c1_m(self): print("c1_m") def m(self): print("C1 m") class C2(): def c2_m(self): print("c2_m") def m(self): print("C2 m") class C3(C2, C1): pass print(C3.__mro__) [PYTHON] Flask 파이썬 웹 프레임워크 from flask import Flask app = Flask(__name__) @app.route("/") def hello(): return "Hello World!" if __name__ == "__main__": app.run() [PYTHON] Random 모듈 난수 생성 함수를 포함한 모듈. https://docs.python.org/3/library/random.html random — Generate pseudo-random numbers — Python 3.8.2 documentation random — Generate pseudo-random numbers Source code: Lib/random.py This module implements pseudo-random number generators for various distributions. For integers, there is uniform selection from a range. For sequences, there is uniform selection of a rando docs.pyt.. [PYTHON] 기본기 강의 복습 , , # 반복문의 큰 종류로는 2가지가 있다. (for, while) # for문과 while문은 상호교환 가능 # while은 보통 무한루프.(while true) for i in range(10): print("철수 : 안녕 영희야, 뭐해?") print("영희 : 안녕 철수야, 그냥 있어.") i = 0 while i =10 and i [PYTHON] 파이썬 예제 뽀개기 텍스트의 첫 단어 출력 def first_word(): word = input() A = word.replace(".", " ") and word.replace("," , " ") A = word.split() print(A[0]) first_word() [PYTHON] 기본 함수 1. 문장이 ~~로 끝나는지 확인 → .endswith() # Python code shows the working of # .endswith() function text = "geeks for geeks." # returns False result = text.endswith('for geeks') print (result) # returns True result = text.endswith('geeks.') print (result) # returns True result = text.endswith('for geeks.') print (result) # returns True result = text.endswith('geeks for geeks.') print (result) 2. A값을 B값으로.. [PYTHON] Beautiful soup [HTML과 XML 파일로부터 원하는 데이터를 추출하는 크롤링 라이브러리] from bs4 import BeautifulSoup from urllib.request import urlopen with urlopen('https://en.wikipedia.org/wiki/Main_Page') as response: soup = BeautifulSoup(response, 'html.parser') for anchor in soup.find_all('a'): print(anchor.get('href', '/')) ○ html 내 타이틀, 바디, url, 텍스트 등 필요로 하는 부분만 뽑아서 정렬 가능. ex) 다음사이트의 인기검색어 추출하기 for A in soup.select("div.slide_favors.. [PYTHON] 생활코딩 복습 : 1번째 : 2번째 : 3번째 ######################################################true, false = 불리언 print('Hello ' + 'world') print('Hello ' * 3) print('Hello' [0]) print('Hello' [1]) print('Hello' [2]) print('hello world'.capitalize()) print('hello world'.upper()) print('hello world'.__len__()) print(len('hello world')) print('Hello world'.replace('world', 'programming')) print("goorm's \"tutorial\"") pr.. 이전 1 2 다음