backend/python 41

파이썬으로 프로그램 만들기: exe화: pyinstaller 사용, 설치

py2exe *python으로 짠 프로그램을 exe화 시키기 exe 파일로 만든다면 우선-python의 다양한 라이브러리가 설치되지 않아도 사용할 수 있고-python이 설치되지 않은 환경에서도 사용할 수 있다. *py2exe는 윈도우에서 사용하는 프로그램이기 때문에... Pyinstaller 를 사용해보았다. 1. pip install pyinstaller 로 설치한다. 2. 터미널로 만든 소스가 있는 폴더로 이동3. pyinstaller --onefile --noconsole --icon="filename.ico" "my_filename"(filiename은 내가 만들고 싶은 이름, my_filename은 내 소스 파일 (보통은 .py겠다) 이름)4. dist 폴더가 생성되는데 이 폴더 안에 파일을 ..

backend/python 2017.01.06

sending gmail by python3

sending email by Python # 이메일을 보내기 위한 smtplib 모듈을 import 한다import smtplib # 그 이후에는 일단 복붙으로 구현--------------------------------------------------------# -*- coding:utf-8 -*- import smtplib TO = "bartkim0426@gmail.com,"SUBJECT = 'Testing email'TEXT = """testing - \nsending email in python \nby seul, loving in suwon""" # plain text # Gmail Sign In gmail_sender = 'bartkim0426@gmail.com' gmail_passwd ..

backend/python 2016.11.23

파이썬 날짜, 시간 관련 모듈

날짜, 시간 관련 모듈 *동작 시간을 알기 위해서import timestart_time = time.time()fun_startend_time = time.time()fun_endexcu_time = end_time - start_time *현재 시간, 날짜 import datetime now = datetime.datetime.now()print(now) # 2015-04-19 12:11:32.669083 nowDate = now.strftime('%Y-%m-%d')print(nowDate) # 2015-04-19 nowTime = now.strftime('%H:%M:%S')print(nowTime) # 12:11:32 nowDatetime = now.strftime('%Y-%m-%d %H:%M:%S'..

backend/python 2016.11.19

파이썬에서 파일 입출력하기

-파일 입력; 파일 객체 = open(파일 이름, 파일 모드)f = open("filename.txt", 'w') #모드; r, w, a, f.close() # 항상 닫아줘야함 -파일 쓰기모드로 열어 출력값f = open("./filename.txt", "w")data = "쓸 내용들"f.write(data) #여기에 쓸 내용을 써서 데이터 입력f.close()=> filename.txt라는 파일이 해당 dir에 생성 - 파일 읽기• readline() 함수 사용; 파일의 첫줄 읽음f = opne("./filename.txt", "r")while True:line = f.readline() # readline()으로 모든 줄 읽기; 쓸모Xif not line: break print(line)f.close..

backend/python 2016.11.19

iterator, generator

*iterator -공간 = iter( 리스트 )ex) a = [0, 1, 2, 3]b = iter(a) ; iterator를 담을 공간 'b'에 iter 함수를 사용하여 a 리스트 인자를 줌-iterator: 공간 'b'가 이터레이터-iteration: b로부터 순차적으로 요소를 가져오는 행위; next() 함수 사용ex) next(b)b.__next__()로 직접 메소드 시행도 가능-iterable: 이더레이션이 가능하다는 의미 -리스트는 iterator가 아니다next(a) => error ('list' object has no attribute 'next')-그렇지만 list는 iterable 하다! (for문) *Generator-함수의 형태로 사용, return 대신에 yield 사용-yiel..

backend/python 2016.11.19

정규표현식-Regular expression

정규표현식 *정규표현식- 메타 문자 1. 숫자, 문자 2.1 "." 쓰는법(DOT)-메타문자 . : 거의 모든 문자열과 일치-줄바꿈 문자인 \n를 제외한 모든 무자와 매치- . 만 단독으로 쓸 경우에는 \. 로 사용 (역슬래쉬)ex) a.b : "a + 모든 문자 + b", 즉 a, b 사이에 모든 문자가 들어가도 매치,*문자클래스[] 안에 dot(.)이 들어가면 . 그대로를 의미 2.2 "\" ( 백슬래쉬)- \s 를 사용할 경우 그 자체임을 알려주기 위해서 \\- "\\section"을 뽑아내기 위해서는 "\\\\section을 써야하는 문제...=> 이런 문제들을 해결하기 위해 Raw string: p = re.compile(r"\\section") #11.17 현재 백슬래쉬 문제 해결 안됨... ..

backend/python 2016.11.17

파이썬 데이터 라이브러리 - 수찬님 강의 2일차 복습 (1), 동적인 웹사이트 크롤링

* 동적인 웹 사이트 크롤링 -동적인 웹사이트 확인: Javascript를 껐을 때 동작이 안되면 동적인 사이트(web developer로 javascript disable) *크레딧잡을 크롤링 해보았다(기본적으로 requests, json 등은 import 해 준 상태여야 한다)----------------------------------------------------------------------------------------------------KEYWORD_URL = "https://kreditjob.com/api_ver2/searchData?q=" DETAIL_URL = "https://kreditjob.com/api_ver2/getInfoByQueryPkNm?query=" # = 뒤의 공..

backend/python 2016.11.08