Python
-
Python문법 - 예외 try except else finally assert raisePython 2018. 2. 1. 10:01
참고Python예제: http://infos.tistory.com/1982 * 예외 접수 기본 구조try: except '예외 처리'except 예외종류 as 예외값 print('예외 처리'.format(예외값)) '사용자 정의 클래스 에러도 가능하다. ex: except UserEcp as ue'except '예외 처리'except:'그외 모든 예외'pass #예외 회피else: #생략 가능 finally: #생략 가능 * 예외 발생 raise NotImplementedErrorraise NameError("NameMessage123") assert A is B #참이 아닐 경우 예외 발생 * 많이 쓰이는 except 종류ZeroDivisionError: #0으로 나눌 없다.IndexError: #인덱..
-
Python예제 - string, join, split, find, startswith, endswith, strip, formatPython 2018. 1. 31. 09:28
참고Python예제: http://infos.tistory.com/1982 "And".join(["V1", "V2", "V3"]) # 'V1AndV2AndV3'"".join(["V1", "V2", "V3"]) # 'V1V2V3' "aassddssff".split("ss") # ['aa', 'dd', 'ff']"aassddssff".split("ss", 1) # ['aa', 'ddssff'] "aassddssff".find("ss") # 3"aassddssff".find("ss", 3, 8) # 6 "aassddssff".startswith("aa")True"aassddssff".endswith("sf")False"aassddssff".endswith(("sf", "ff"))True "{0} and {1}..
-
Python예제 - 문자열 속 특수문자 변환Python 2018. 1. 31. 09:12
참고Python예제: http://infos.tistory.com/1982Python예제 - 문자열, 가입, 분할, 찾기, 시작, 끝, 스트립, 형식 : http://infos.tistory.com/1567Python예제 - string.digits string.ascii_letters : http://infos.tistory.com/1566 Python예제 - 문자열 속 특수문자 변환: http://infos.tistory.com/1565Python예제 - ord, hex, chr: http://infos.tistory.com/1564Python함수 - Cmp 비교: http://infos.tistory.com/1563Python예제 - SMTP Email: http://infos.tistory.com..
-
-
Python Re - 정규식, RegularExpressionPython 2018. 1. 30. 23:23
Python예제 - 정규식, 정규표현식, re, RegularExpression * Python 함수 메소드 설명 compile(pattern[, flags]) 입력된 pattern을 컴파일하여 정규식 객체를 리턴 match(pattern, string[, flags]) string의 앞부분에 pattern과 일치하는 검사 하여 MatchObject 리턴 search(pattern, string[, flags]) string의 전체중 pattern과 일치하는 곳이 있는지 찾아 MatchObject 리턴 split(pattern, string[, flags]) pattern을 구분자로 string을 분리하여 리스트로 리턴 findall(pattern, string[, flags]) string에서 patt..