본문 바로가기

파이썬10

Lecture 94 - Python(11) WordCount Method hadoop에서 Python 사용하기 Project Assignment WordCounting in Python and Hadoop 1. python - 구글링 사이트 -> 워드카운트하는 프로그램 짜기 - 워드문서 - 소스 2. hadoop - standalone 사이트 -> 워드카운트 - 워드문서 -> 스크린샷 1. Python Word Count ''' Created on 2018. 10. 5. @author: kitcoop ''' import re with open('C:/Python/eclipse-workspace/AssignmentEx01/4300-0.txt', 'r', encoding='utf-8-sig') as file: data = file.read() # 정규식 사용 해당 문자를 공백화 .. 2019. 8. 14.
Lecture 90 - Python(10) xml, html, json 처리법, 정규식 사용법 원격데이터 xml html(웹페이지) json * csv 문자열 중심(X) https://docs.python.org/3/library/markup.html https://wikidocs.net/42 => 위키독스에서 7장 파이썬도구들 -> 파이썬으로 XML처리하기 -> XML문서생성하기에서 저 내용 복사해서 이클립스에서 복사붙여넣기 파이썬으로 XMl 처리하기 XML 문서 생성하기 DataEx01.note.xml Tove Jani ''' parser = HTMLParser() parser.feed(html.strip()) print(parser.get_starttag_text()) parser.close() 콜 백 자동적으로 문서를 분석해줌 from html.parser import HTMLParser .. 2019. 8. 6.
Lecture 89 - Python(9) url 관련 함수들, 데이터 크롤링, geocoding을 이용한 위치 검색 network URL - url string 관련 클래스 URLConnection - 접속 관련 클래스 - google geolocation xml(json) - jstl (proxy) => urllib 패키지 Socket https://docs.python.org/ko/3/library/urllib.html URLEx01.ex01 - urlparse from urllib.parse import urlparse url = urlparse('https://search.naver.com/search.naver?where=nexearch&sm=top_hty&fbm=1&ie=utf8&query=starwars') print(url) from urllib.parse import urlparse url = urlp.. 2019. 8. 5.
Lecture 88 - Python(8) 파이썬을 이용한 우편번호 검색기, nCloud에 python 3 설치 파이선을 활용한 우편번호 검색기 - 강사님 Version ZipSearch.migrationEx01 file = open('zipcode_seoul_utf8_type2.csv', 'r', encoding='utf8') line = file.readline() while line: lines = line.split(',') # statement처럼 print("insert into zipcode values(%s, '%s', '%s', '%s', '%s', '%s', '%s')" %\ (lines[6], lines[0], lines[1], lines[2], lines[3], lines[4], lines[5])) line = file.readline() file.close() ncloud mariadb에서 .. 2019. 8. 1.
Lecture 86 - Python(7) 파이썬에 데이터베이스 연결 데이터베이스를 연결해 보자 python 데이터베이스 연결 내장 데이터베이스 (+API) sqlite(초경량형 데이터베이스 - 파일 - SQL 문) 외부 데이터베이스(API 추가) MySQL, Oracle, DB2 ... * MySQL(mariadb) - python mysqlclient-1.3.13-cp36-cp36m-win_amd64.whl -> zip C:\Python\Python36\Lib\site-package에서 압축 풀기 공식사이트 - 버전때문 => http://www.lfd.uci.edu/~gohlke/pythonlibs/ mac에서 설치 하는법 아래 참조 Mac OS X Python 3 MySQL 연동 MySQL 접속법 C:\Users\kitcoop>cd C:\Program Files\My.. 2019. 7. 30.
Lecture 85 - Python(6) 패키지, 내시스템정보확인, 시간, 날짜, webbrowser 패키지 패키지(Packages)는 도트(.)를 이용하여 파이썬 모듈을 계층적(디렉터리 구조)으로 관리할 수 있게 해준다. 예를 들어 모듈명이 A.B인 경우 A는 패키지명이 되고 B는 A 패키지의 B 모듈이 된다. 패키지 안에 모듈이 있는 개념인건가... 패키지 만들기 패키지 기본 구성 요소 준비하기 __init__.py만들기 __init__.py만들기 __init__.py만들기 echo.py 만들기 render.py 만들기 echo.py def echo_test(): print('echo') render.py def render_test(): print('render') 패키지 안의 함수 실행하기 Ex04.ex01 #1 # import game.graphic.render # import game.soun.. 2019. 7. 26.
Lecture 84 - Python(5) 클래스와 객체, 모듈 클래스 클래스 구조 만들기 객체에 숫자 지정할 수 있게 만들기 ''' Created on 2018. 9. 14. @author: kitcoop ''' # 함수(function) def func1(): print('func1() 호출') def func2(first): print('func2() 호출 : {0}'.format(first)) class FourCal : # 메서드 def cfunc1(self): print('cfunc1() 호출') # self = this print(self) def cfunc2(self, first): print('cfunc2() 호출 : {0}'.format(first)) a = FourCal() print(type(a)) func1() a.cfunc1() func2(1.. 2019. 7. 25.
Lecture 83 - Python(4) 사용자 입력과 출력, 주민번호유효검사, 파일읽고쓰기, 내장함수 사용자 입력과 출력 input의 사용 num1 = input('숫자를 넣어줘 : ') print('num1 : {0}'.format(num1)) 명령프롬프트로 실행해보자 C:\Users\kitcoop>cd c:\Python\eclipse-workspace\Ex01 c:\Python\eclipse-workspace\Ex01>python input.py 숫자를 넣어줘 : 1 num1 : 1 숫자 여러개 실행하기 num1 = input('숫자를 넣어줘 : ') print('num1 : {0}'.format(num1)) num2 = input('숫자를 넣어줘 : ') print('num1 : {0}'.format(num2)) num3 = input('숫자를 넣어줘 : ') print('num1 : {0}'.fo.. 2019. 7. 24.