본문 바로가기

Python_Beginer

(145)
Python 수강 노트 4 - 아나콘다 설치- C:/사용자/계정/내 문서에 소스 파일 붙이기- 주피터 노트북 실행- 크롬 브라우저 실행됨(주피터 노트북 커맨드 종료하면 안됨)- 워크스페이스 공간은 내 문서로 지정된다.- 5장 폴더 - cho5_px- rename - 파일 이름 변경 후 중간중간 file - save and chkpoint(ctrl + s)- def - 책자 89 ~-int a, b:a = 1b = 2 int add(c, d){e = c + d;retrun e;} int main(){print('%d', add(a, b)}- 람다에 해석은 뒤에서부터 앞으로 해석한다.- 클래스 : 객체지향적인 특징 따로따로 완성품을 모아 또 다른 완성품을 만드는 것.- 서로 연관 있는 변수들과 함수들을 이쁘게 묶어두..
190217> Python 정규표현식 연습 import re data = """ park 800905-1049118 kim 700905-1059119 """ pat = re.compile('(\d{6})[-]\d{7}') # 숫자 6자리 - 숫자 7자리 # print(pat.sub('\g', data)) # 0은 전체를 의미 # print(pat.sub('\g', data)) # 1은 \d{6} # print(pat.sub('\g', data)) # 2는 \d{7} print(pat.sub('\g-*******', data)) # 뒷자리를 *로 마킹 import re s = 'Apple is a big company and apple is very delicious.' c = re.compile('apple') result = c.findall(..
[함수]str를 int로 변환하는 함수 def str2int(slist): nlist = [] for s in slist: nlist.append(int(s)) return nlist str를 불러와 int로 변환하는 함수
[함수]list를 dict로 만드는 함수 def list2dict(lists, keys): dicts = {} for l in lists: k = l[0] temp = {} for i in range(0, len(keys)): temp[keys[i]] = l[i + 1] dicts[k] = temp return dicts list를 불러와서 dict로 변환하는 함수
[함수]csv를 list로 만드는 함수 def csv2list(filename): import csv file = open(filename, 'r') csvfile = csv.reader(file) lists = [] for item in csvfile: lists.append(item) return lists csv를 파일을 불러와 리스트로 변환하는 함수. # CSV를 2차원 인덱스로 만들어서 DATA 분석 def csv2list(filename): lists = [] file = open("파일경로\test.csv", "r") while True: line = file.readline().rstrip("\n") if line: line = line.split(",") lists.append(line) else: ..
Python 수강 노트 3 - 파이썬 기본 문법(정규식)- 크롤링 / 빅데이터처리- 장고(블로그앱)- https://blog.naver.com/sdw1904 선생님 블로그 자료 공유- 점프 투 파이썬 전자교재 다운로드- 파이썬 / 파이참 다운로드 설치(환경 설정 변수)- 정규 표현식(ch07) 정규표현식(Regular Expressions) 복잡한 문자열을 처리할때 사용하는 기법 모든 곳에서 사용- 디버깅시 한줄 한줄 프린터를 해서 보면 편하다.- 정규표현식 1. 문자 클래스 [](character class) 문자 클래스로 만들어진 정규식은 "[와 ] 사이의 문자들과 매치"라는 의미를 갖는다. ^ 메타 문자가 사용될 경우에는 반대(not)라는 의미를 갖는다.[^0-9]라는 정규 표현식은 숫자가 아닌 문자만 매치..
Python 수강 노트 2 - Python 사용 버전 : 3.7.x- Python 사이트 : https://www.python.org/(add path 포함 설치)- 수업 교재 참조 사이트 : https://wikidocs.net/book/1- 사용 에디터 : 파이참(https://www.jetbrains.com/pycharm/download/#section=windows) - 2진수- bit 정보의 최소단위- 1byte = 8bit- 한글 = 2byte(16bit)- 영어 = 1byte(8bit)- MSB(most significant bit, msb) : 최상위 비트이진수 내에 의미하는 특정 비트에서, 그것은 그 숫자에서 비트수보다 하나 적은 방향으로 0에서 각 비트를 비트수로 할당하는게 일반적이다.그러나 이 할당을 사용하는 ..
Python 수강 노트 1 1. Python Downloads : http://www.python.org - version x.y.zx : Majory : MinorZ : Patch특성상 : x y 만 따지고 z 는 따로 안따진다. - 아키텍쳐 종류x86 : 32bit(i386, i486, i586, i686)x64 : 64bit(ia)x86_64 : 32bit 이나 64bit를 처리 할 수 있게 만듬(AMD64, EM64T)windows x86-64 executable installer -> downloads 2. NotePad++ Downloads : http://notepad-plus-plus.org ======================================================================..