목록Python (10)
하고재비
1234567891011121314151617181920212223from urllib.request import urlopenimport urllib.requestfrom bs4 import BeautifulSoup html = urlopen('######################')soup = BeautifulSoup(html, 'lxml') # 996 - 1002pic_main = [] for x in range(996, 1003): pic_main_list = soup.find('img', {'id': 'eListPrdImage' + str(x) + '_1'}).get('src') pic_main.append(pic_main_list) f = open("#################", 'w..
기사내용 TXT 저장 12345678910111213141516171819202122232425from urllib.request import urlopenfrom bs4 import BeautifulSoup html = urlopen('http://news.naver.com/main/read.nhn?mode=LSD&mid=shm&sid1=103&sid2=245&oid=020&aid=0003113573')# html = urlopen('file:///C:/Users/USER/Desktop/songsong.html')#html = urlopen('https://dak.gg/profile/DeadDE/2017-pre6/krjp')soup = BeautifulSoup(html, 'lxml') #nameList..
from urllib.request import urlopen from bs4 import BeautifulSoup for i in range(26600, 26630): URL = 'http://www.inven.co.kr/board/overwatch/4676/' + str(i) html = urlopen(URL) soup = BeautifulSoup(html, 'lxml') contents_1 = soup.find_all('div',{'class':'articleCategory'}) if len(contents_1) != 0: if "[영웅]" in contents_1[0].get_text(): contents = soup.find_all('div', {"class": "articleTitle"}) p..
st = [0 for _ in range(10)] index = 10 value = 0
import os def search(dirname): try: filenames = os.listdir(dirname) for filename in filenames: full_filename = os.path.join(dirname, filename) if os.path.isdir(full_filename): search(full_filename) else: ext = os.path.splitext(full_filename)[-1] if ext == '.py': print(full_filename) except PermissionError: pass search("C:/") if ext == '.py':
import matplotlib.pyplot as plt from matplotlib import font_manager, rc font_name = font_manager.FontProperties(fname="c:/Windows/Fonts/malgun.ttf").get_name() rc('font', family=font_name) temp = [29, 29, 28, 30, 31, 31, 32] temp_min = min(temp) temp_max = max(temp) temp_sum = sum(temp) temp_avg = sum(temp) / len(temp) print(temp_min) print(temp_max) print(temp_sum) print(temp_avg) x = [1, 2, 3,..
클래스란 함수(메소드)와 변수(필드)를 하나의 단위로 묶는 방법 12345678910111213class Car: color= " " model= " " def drive(self): self.speed = 10 myCar = Car()myCar.color = "blue"myCar.model = "E-Class" myCar.drive() # 객체 안의 drive() 메소드가 호출된다. print(myCar.speed) # 10이 출력된다. Colored by Color Scriptercs객체의 기본 구성과 필드 메소드 선언, 메소드 사용7번줄처럼 객체 선언 -> 8번, 11번처럼 객체 내 필드와 메서드 사용 메소드1234def 함수명(입력 인수): ...cs 클래스 안에서 선언된 함수들메소드들의 매개변수..
딕셔너리(dictionary)도 리스트와 같이 값을 저장. 값(value)과 관련된 키(key)가 있다. 12345678910>>> phone_book = { }>>> phone_book["홍길동"] = "010-1234-5678">>> print(phone_book){'홍길동': '010-1234-5678'} >>> phone_book["강감찬"] = "010-1234-5679">>> phone_book["이순신"] = "010-1234-5680">>> print(phone_book) {'홍길동': '010-1234-5678', '강감찬': '010-1234-5679', '이순신': '010-1234-5680'}cs 1. Dict 선언 및 데이터 추가 12345678910>>> print(phone_b..
List 여러 개의 데이터를 하나로 묶어서 저장 123456>>> heroes = [ ]>>> heroes.append("아이언맨")['아이언맨']>>> heroes.append("닥터 스트레인지")>>> print(heroes)['아이언맨', '닥터 스트레인지']cs 1. python list 선언 및 데이터 추가 ( .append ) Value and Index Value A B C D Index 1 2 3 4 index 값을 이용하여 각 항목으로 접근이 가능하다. 1234567>>> letters = ['A', 'B', 'C', 'D', 'E', 'F']>>> print(letters[0])A>>> print(letters[1])B>>> print(letters[2])CColored by Color..
변수 기본 입출력 - 변수 선언에 변수형 기재 안함. - 세미콜론을 쓰지않음. - 출력문 내 변수 사용법 " " , ' ' 괄호사용 1234x = 100y = 200sum = x+yprint(x ,"와", y ,"의 합은", sum ,"입니다.")cs - 형변환 - input 이용한 입력 123456name = input("이름을 입력하세요 :")print(name,'씨, 안녕하세요?')x = int(input("첫번째 정수를 입력하세요 : "))y = int(input("첫번째 정수를 입력하세요 : "))print(x,"와",y,'의 합은', x+y,'입니다')cs 계산 - 나누기 연산자/ 나누기 // 몫 % 나머지 - 초를 '시간 : 분 : 초' 로 계산하여 출력 12345678sec = 4000ti..