본문 바로가기

python

(197)
Python - DaumMail Auto Login(다음 메일 자동 로그인) from selenium import webdriver from selenium.webdriver.common.keys import Keys driver = webdriver.Chrome('C:/chromedriver/chromedriver') driver.implicitly_wait(3) # daum.net 자동 로그인 driver.get('https://logins.daum.net/accounts/loginform.do?url=https%3A%2F%2Fmail.daum.net%2F') driver.find_element_by_name('id').send_keys('DaumID') # 다음 아이디 입력 driver.find_element_by_name('pw').send_keys..
Python Game - 폭탄 돌려 최종 승자 구하기 # findbomb()은 플레이어목록에서 탈락자의 index를 반환하는 함수 def findbomb(players, start, step): index = (start + step) % len(players) return index # players = input("플레이어들을 빙둘러선 순서로 입력: ").split() players = ['B', 'K', 'M', 'A', 'C', 'D', 'P'] print("플레이어들의 목록: {}".format(players)) start = int(input("시작 위치를 0 이상의 숫자로 입력하세요: ")) step = int(input("간격을 몇 사람으로 할까요: ")) while len(players) > 1: index = findbomb(players..
190302>Python - Naver 증권 일일 시세 크롤링 Q. Naver 증권 일일 시세 크롤링 하기(금융코드 035420) A.import requests from bs4 import BeautifulSoup as BS def refine_price(text): price = int(text.replace(",", "")) return price url = "https://finance.naver.com/item/sise_day.nhn?code=035420" response = requests.get(url) text = response.text html = BS(text, 'html.parser') tr_list = html.find_all("tr", {"onmouseover":"mouseOver(this)"}) for tr in tr_list: date ..
Python - Class1 ~ 3까지의 첨부파일을 읽어들여서 한 파일로 만들기(부제. 평균) class1 ~ 3의 파일은 각 각의 내용을 가지고 있다.이것을 한 개의 파일로 만들어보고 평균을 구해서 추가하자. import csv students = [] for num in range(1, 4): filename = "class{}.csv".format(num) file = open(filename, "r") csvfile = csv.reader(file) for item in csvfile: sum = 0 for score in item[1:]: sum += int(score) avg = sum / (len(item) - 1) item.append(avg) students.append(item) file = open("students1.csv", "w", newline = "")..
CSV를 2차원 인덱스로 만들어서 DATA 분석 def csv2list(filename): lists = [] file = open("C:\\Users\\ankiwoong\\PycharmProjects\\study\\더조은컴퓨터 학원 - 기초 프로그래밍\\Data\\accounts.csv", "r") while True: line = file.readline().rstrip("\n") if line: line = line.split(",") lists.append(line) else: break return lists accounts = csv2list("C:\\Users\\ankiwoong\\PycharmProjects\\study\\더조은컴퓨터 학원 - 기초 프로그래밍\\Data\\accounts.csv") print(accounts)첨부파일에 있..
Magic Commands Line magics%aliasDefine an alias for a system command.‘%alias alias_name cmd’ defines ‘alias_name’ as an alias for ‘cmd’Then, typing ‘alias_name params’ will execute the system command ‘cmd params’ (from your underlying operating system).Aliases have lower precedence than magic functions and Python normal variables, so if ‘foo’ is both a Python variable and an alias, the alias can not be execute..
Python - for 문을 활용하여 복잡한 도형 만들기 1. for문을 활용하여 복잡한 도형 만들기import turtle as t t.shape('turtle') t.speed('fastest') for i in range(400): t.forward(i) t.left(90) 2. 실행 화면
Python - for 문을 활용하여 복잡한 원 그리기 1. for문을 활용하여 복잡한 원 그리기import turtle as t n = 60 t.shape('turtle') t.speed(10) #속도 : 'fastest': 0 / 'fast': 10 / 'normal': 6 / 'slow': 3 / 'slowest': 1 for i in range(n): t.circle(120) t.right(360 / n) 2. 실행 화면