프로그래밍
-
모듈과 패키지 사용Python 2023. 10. 30. 11:14
모듈: 특정 기능을 .py 파일 단위로 작성한 것 패키지: 특정 기능과 관련된 여러 모듈을 묶은 것, 패키지는 모듈에 네임스페이스(이름 공간)를 제공 라이브러리: 파이썬에 기본으로 설치된 모듈과 패키지, 내장 함수를 묶어서 파이썬 표준 라이브러리라 부름 import로 모듈 가져오기 · import 모듈 · import 모듈1, 모듈2 · 모듈.변수 · 모듈.함수() · 모듈.클래스() >>> import math >>> >>> math.pi >>>3.141592653589793 >>> >>> math.sqrt(4) 2.0 >>> math.sqrt(2) 1.4142135623730951 import as로 모듈 이름 지정 >>> # import 모듈 as 이름 >>> import math as m >>> ..
-
SQL 기본 문법데이터베이스/SQL 2023. 10. 27. 14:52
DBname : DBMADANG CREATE TABLE Book ( bookid NUMBER(2) PRIMARY KEY, bookname VARCHAR2(40), publisher VARCHAR2(40), price NUMBER(8) ); CREATE TABLE Customer ( custid NUMBER(2) PRIMARY KEY, name VARCHAR2(40), address VARCHAR2(50), phone VARCHAR2(20) ); CREATE TABLE Orders ( orderid NUMBER(2) PRIMARY KEY, custid NUMBER(2) REFERENCES Customer(custid), bookid NUMBER(2) REFERENCES Book(bookid), salepr..
-
자바스크립트 기본 문법HTML 2023. 10. 26. 17:34
기본 용어 표현식: 값을 만들어 내는 간단한 코드 문장: 프로그래밍 언어에 실행할 수 있는 코드의 최소 단위 문장 마지막에 세미콜론(;) 또는 줄 바꿈을 넣어 종결을 나타냄 273; 10 + 20 + 30 * 2; var name = '윤' + '인' + '성'; alert('Hello JavaScript'); 문장 예 273 10 + 20 + 30 * 2 'JavaScript' 표현식 예 키워드 자바스크립트를 처음 만들 때 정해진 특별한 의미가 부여된 단어 식별자 자바스크립트에서 변수나 함수 등에 이름을 붙일 때 사용하는 단어 키워드 사용 x 특수 문자는 _와 $만 허용 숫자로 시작하면 x 공백 입력 x 구분 단독으로 사용 다른 식별자와 함께 사용 식별자 뒤에 괄호 x 변수 속성 식별자 뒤에 괄호 o ..
-
MariaDB 유틸리티 사용법데이터베이스/SQL 2023. 10. 26. 14:09
HeidiSQL 기능으로 SQL문 자동 생성 앞서 생성했던 memberTBL을 SQL문으로는 이와 같이 사용 INSERT문 자동 생성 데이터 탭 클릭 메뉴의 도구 > 격자 행 내보내기 선택 확인 누른 후 메모장 켜서 붙여넣기 하면 INSERT문 확인됨 유지보수 기능 데이터베이스 목록의 localhost 우클릭 > 유지보수 check 실행 check: 테이블의 오류 등이 있는지 모두 체크해 결과를 알려 줌 Analyze 실행 Analyze: 테이블 키의 분포 등 분석하고 저장
-
정규표현식Python 2023. 10. 25. 17:12
일정한 규칙(패턴)을 가진 문자열을 표현하는 방법 문자열 판단하기 re 모듈을 가져와 사용(re는 regular expression의 약자) >>> # re.match('패턴', '문자열') >>> >>> import re >>> >>> re.match('Hello', 'Hello, world') # 문자열이 있으므로 정규표현식 매치 객체 반환 >>> >>> re.match('python', 'Hello, world') # 문자열이 없으므로 아무것도 반환되지 않음 >>> >>> re.match('python', 'Hello, python') >>> 문자열이 맨 앞에 오는지 맨 뒤에 오는지 판단 ^문자열: 문자열이 맨 앞에 오는지 판단 / 문자열$: 문자열이 맨 뒤에 오는지 판단(특정 문자열로 끝나는지) ..
-
데코레이터(장식자)Python 2023. 10. 25. 13:50
장식하는 도구 클래스에서 메서드를 만들 때 @staticmethod, @classmethod, @abstractmethod 등을 붙였는데 @로 시작하는 것들이 데코레이터 > 함수(메서드)를 장식 데코레이터 만들기 데코레이터는 함수를 수정하지 않은 상태에서 추가 기능을 구현할 때 사용 예를 들어 지금까지는 시작과 끝을 출력하고 싶다면 함수 시작, 끝 부분에 print를 넣어야 함 > 번거로움 def hello(): print('hello 함수 시작') print('hello') print('hello 함수 끝') def world(): print('world 함수 시작') print('world') print('world 함수 끝') hello() world() # 실행 결과 hello 함수 시작 hell..
-
코루틴Python 2023. 10. 24. 16:29
지금까지 함수를 호출한 뒤 함수가 끝나면 현재 코드로 돌아옴 def add(a, b): print('add 함수 실행') c = a + b # add 함수가 끝나면 변수와 계산식은 사라짐 return c def clac(): print('clac 함수 실행') r = add(1, 2) # add 함수가 끝나면 다시 clac 함수로 돌아옴 print('결과:', r) clac() # 실행 결과 clac 함수 실행 add 함수 실행 결과: 3 ↑ 예제, clac 함수 안에서 add 함수를 호출했을 때 add 함수가 끝나면 다시 clac 함수로 돌아옴 add 함수가 끝나면 함수에 들어 있던 변수와 계산식은 모두 사라짐 clac가 메인 루틴이면 add가 서브 루틴 코루틴(coroutine)은 cooperativ..