본문 바로가기
  • Let's go grab a data
반응형

파이썬7

정규표현식 정규표현식String.find()는 일치 문자열 탐지, 정규표현식은 패턴 부합 탐지https://emailregex.com/ 참고 with open('wiki/turing.txt', encoding='utf-8') as fp: turing = fp.read()print(turing)앨런 매티슨 튜링(영어: Alan Mathison Turing, OBE, FRS, 1912년 6월 23일 ~ 1954년 6월 7일)은 영국의 수학자, 암호학자, 논리학자이자 컴퓨터 과학의 선구적 인물이다. 알고리즘과 계산 개념을 튜링 기계라는 추상 모델을 통해 형식화함으로써 컴퓨터 과학의 발전에 지대한 공헌을 했다.[2][3][4] 튜링 테스트의 고안으로도 유명하다. ACM에서 컴퓨터 과학에 중요한 업적을 남긴 사람들에게 매년.. 2018. 12. 12.
BeautifulSoup 크롤러 기본 BeautifulSoup 크롤러 기본 import requestsurl = 'https://ko.wiktionary.org/wiki/%EB%B6%80%EB%A1%9D:%EC%9E%90%EC%A3%BC_%EC%93%B0%EC%9D%B4%EB%8A%94_%ED%95%9C%EA%B5%AD%EC%96%B4_%EB%82%B1%EB%A7%90_5800'response = requests.get(url)print(response.text[:100]) 2018. 12. 12.
파이썬 자연어 처리 기초(NLTK) \이미지 출처: 자연어 처리 입문 강의 자료 (이성주) pypi https://pypi.org/project/nltk/ 서울대 http://konlpy.org/en/latest/ GPL v3 오픈소스 라이선스구글 https://cloud.google.com/natural-language/ import nltknltk.download()from nltk.corpus import gutenberggutenberg.fileids() #파일 목록#nltp에서 제공하는 corpus 리더기raw_text = gutenberg.raw('austen-emma.txt')print(raw_text[:100]) #raw 리더기를 안쓰는 경우 아래와 같이 path작업을 계속해줘야함import osos.path.join(gut.. 2018. 12. 10.
Word, pdf 문서에서 문자열 추출하기, 파일 입출력, 인코딩 [문서에서 문자열 추출] https://pypi.org/project/pyautomate/ > pip install pyautomate import pyautomatefrom pyautomate.office import Worddocx = Word('test.docx') from pyautomate.pdf import PDFDocumentpdf = PDFDocument('test.pdf')본문 = pdf.extract_text()print(본문) [파일 입출력]file = open('test.txt')filebody = file.read()file.close()print(body) #파이썬 스타일with open('test.txt') as file: body = file.read() print(body).. 2018. 12. 10.
자료형 - List #리스트 : 객체들의 순서가 있는 모임Collection#[], len(), max(), min(), count()a_list = [1,2,3]print("Output #58: {}".format(a_list))print("Output #59: {}".format(len(a_list)))print("Output #60: {}".format(max(a_list)))print("Output #61: {}".format(min(a_list)))another_list = ['printer',5,['star','circle',5]]print("Output #62: {}".format(another_list))print("Output #63: {}".format(len(another_list)))print("Out.. 2018. 2. 13.
Hello python, ipynb 파일 py 파일로 만들기, 실행, 자료형 jupyter notebook을 열고 하단의 스크립트를 작성하여 first_script.ipynb로 저장하고 실행한다print("Output #1: hello python")Output #1: hello python x=4y=5z=x+yprint("Output #2: four plus five equals {0:d}.".format(z))Output #2: four plus five equals 9. a=[1,2,3,4]b=["first","second","third","fourth"]c=a+bprint("Output #3: {0},{1},{2}".format(a,b,c))Output #3: [1, 2, 3, 4],['first', 'second', 'third', 'fourth'],[1, 2, 3, 4.. 2018. 1. 9.
MNIST 데이터 집합 읽어오기, 이미지로 나타내기 MNIST 데이터 집합 읽어오기, 이미지로 나타내기 MNIST 데이터는 머신 러닝 분야에서 광범위하게 사용되는 손글씨 숫자 0~9가 흑백으로 저장된 이미지 [데이터 다운로드]http://yann.lecun.com/exdb/mnist/ ( train-images-idx3-ubyte.gz, train-labels-idx1-ubyte.gz, t10k-images-idx3-ubyte.gz, t10k-labels-idx1-ubyte.gz) [입력을 도와주는 스크립트 다운로드]https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/tutorials/mnist/input_data.py Python 스크립트와 동일한 폴더에 input_data... 2017. 4. 14.
반응형