본문 바로가기

전체 글174

[Python] 표준 라이브러리 파이썬 표준 라이브러리는 파이썬을 설치할 때 자동으로 컴퓨터에 설치된다.sys, re 모듈은 파이썬의 중요한 표준 라이브러리이다.시간 관련datetime.datedatetime.date는 연, 월, 일로 날짜를 표현할 때 사용하는 함수import datetimeday1 = datetime.date(2021, 12, 14)day2 = datetime.date(2023, 4, 5)diff = day2 - day1diff.days# 477요일은 datetime.date 객체의 weekday 함수를 사용하면 쉽게 구할 수 있다.>>> day = datetime.date(2021, 12, 14)>>> day.weekday()1>>> day.isoweekday()2함수월화수목금토일weekday()0123456iso.. 2025. 1. 12.
[Python] 내장 함수 내장 함수는 파이썬 모듈과 달리 import가 필요하지 않기 때문에 아무런 설정 없이 바로 사용할 수 있다.함수내용예시abs(x)abs(x)는 어떤 숫자를 입력받았을 때그 숫자의 절댓값을 리턴>>> abs(-3)3all(x)반복 가능한 데이터 x를 입력값으로 받고,x의 요소가 모두 참이면 True,하나라도 거짓이면 False를 리턴>>> all([])False>>> all([1, 2, 3])Trueany(x)반복 가능한 데이터 x를 입력으로 받고,x의 요소 중 하나라도 참이 있으면 True를 리턴,x가 모두 거짓일 때만 False를 리턴>>> any([1, 2, 3, 0])True>>> any([])Falsechr(i)유니코드 숫자 값을 입력받아 그 코드에 해당하는 문자를 리턴>>> chr(97)'a'd.. 2025. 1. 12.
[Python] 클래스, 모듈, 패키지, 예외처리 클래스# 계산기 만들기class Calculator: def __init__(self): self.result = 0 def add(self, num): self.result += num return self.result def sub(self, num): self.result -= num return self.result# 클래스 내부 메서드 호출cal1 = Calculator()print(cal1.add(3))print(cal1.add(4))print(cal1.sub(1))# 클래스명으로 호출print(Calculator.add(cal1, 2))class FourCal: def set_data(self, first, second): self.first =.. 2025. 1. 12.
[React] function - export가 없는 경우, export가 있는 경우: export, export default의 차이 export가 없는 경우, export가 있는 경우: export, export default의 차이export가 없는 경우exportexport default모듈의 내부에서만 사용 가능여러 개의 이름 있는 항목을 내보낼 수 있다.모듈당 하나의 기본 내보내기를 지정할 수 있다. import할 때는 반드시 해당 이름을 사용import할 때는 원하는 이름으로 사용export가 없는 경우, 해당 함수는 모듈의 내부에서만 사용 가능하며, 외부에서 접근할 수 없다.export가 있는 경우,export 키워드를 사용하면 해당 함수가 모듈의 외부에서 접근 가능하다는 것을 의미. // file-A.jsexport function Component() { ... }다른 파일이나 모듈에서 이 함수를 import하여 사용할.. 2025. 1. 12.
[React] React Hook[State, Effect, Ref, Context, Memo, Callback, Reducer, customHook] useStateconst [현재 상태, 상태 변경] = useState(초기값)무거운 작업을 하는 초기 값을 콜백함수로 불러오면 최초 한 번만 값을 불러온다.import React from 'react';import { useState } from 'react';// state: 컴포넌트의 상태// const [현재 상태, 상태 변경] = useState(초기값)const heavyWork = () => { console.log('무거운 작업'); return ['홍길동', '고길동'];};export default function useStateHooks() { // 클릭 시 시간 증가 시키기 const [time, setTime] = useState(1); const handleClick =.. 2025. 1. 11.
[React] react.dev > react 빠르게 시작하기 먼저 vite를 이용해서 리엑트를 설치했다.npm create vite@latest ./이후 react와 js를 선택했다. 최초 폴더구조는 사진과 달라서 정리하기 쉽도록 사진처럼 구조를 바꿔 주었다.react 흐름: index.html -> main.jsx (or index.jsx) -> App.jsx import { StrictMode } from 'react';import { createRoot } from 'react-dom/client';import './styles/index.css';import App from './App';createRoot(document.getElementById('root')).render( ,);import './styles/App.. 2025. 1. 10.
[React] .html에서 react 사용, React의 동작 원리 js로 ui 업데이트 하기 React - DOM 사용하기 컴포넌트로 ui구축 props 사용법 Props 사용법1) .을 사용한 객체 속성function Header(props) { return {props.title};}2) template literalfunction Header({ title }) { return {`Cool ${title}`};}3) 함수의 반환function createTitle(title) { if (title) { return title; } else { return 'Default title'.. 2025. 1. 9.
MAC 명령어, 단축키 + tree 명령어 MAC 명령어와 단축키 + tree 명령어명령어숨김 파일 보기: ls - a 사용하려는 포트가 사용 중인지 보기(ex) 8080): lsof -i :8080사용중인 포트 끄기 (숫자는 PID): kill 48296(PID) 단축키숨김 파일 보기 : command + shift + . Tree Homebrew 설치 :/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"tree 설치: brew install tree기본 사용법기본 동작: 지정된 디렉토리 또는 현재 디렉토리의 파일 및 폴더를 트리 형태로 출력예시:tree [디렉토리 경로]현재 디렉토리부터 시작해서 하위 디렉토리 및 파일들을 트.. 2025. 1. 9.
[Python] 입출력 함수# 함수구조 : # def 함수_이름(매개변수): # 수행할_문장1 # 수행할_문장2 # ... # return 리턴값def add(a, b): return a + bdef add2(a, b): result = a + b return resulta = 1b = 2c = add(a, b)d = add2(a, c)print(d)# 입력값이 없는 함수 == 사용 시: 리턴값을_받을_변수 = 함수_이름()def say(): return 'hi'a = say()print(a)# 리턴값이 없는 함수 == 사용 시: 함수_이름(입력_인수1, 입력_인수2, ...)def add3(a, b): print('%d, %d의 합은 %d입니다.' % (a, b, a + b))add3(3, .. 2025. 1. 8.
[Postgres] Docker 위 Postgresql 설치 및 권한, 데이터베이스 설정 postgres 받기sudo docker pull postgres:latest도커 컨테이너 실행sudo docker run -d \ --name postgres \ -e POSTGRES_USER=postgres \ -e POSTGRES_PASSWORD=strongpwd \ -e POSTGRES_DB=postgres \ -p 5432:5432 \ -v /your/local/path:/var/lib/postgresql/data \ postgres:latest-d: 백그라운드에서 실행--name: 컨테이너 이름 설정-e: 환경 변수 설정-p: 포트 매핑-v: 데이터 지속성을 위한 볼륨 설정sudo docker logs postgres데이터 베이스 접속docker exec -it postgres p.. 2025. 1. 2.
[Amazon/Linux ubuntu/Docker] AWS Docker OracleDB SpringBoot 로컬에서 실행하는 도커 보기 AWS 리눅스 환경에서 실행하는 도커 보기 도메인 발급 받기, 포트번호 없애기로컬에서 실행하는 도커">로컬에서 실행하는 도커 보기 AWS 리눅스 환경에서 실행하는 도커 보기 도메인 발급 받기, 포트번호 없애기로컬에서 실행하는 도커 Docker: 컨테이너 기술을 사용하여 애플리케이션을 쉽고 일관되게 배포, 실행, 관리할 수 있도록 해주는 플랫폼https://docs.docker.com/desktop/install/windows-install/ WindowsGet started with Docker for Windows. This guide covers system requirements, where to download, and instructions on how .. 2024. 12. 30.
[Python] 제어문 (if, while, for) if문name = Trueif name: print(f'{name}입니다.');else: print(f'{name}입니다.') # x or y x와 y 둘 중 하나만 참이어도 참이다.# x and y x와 y 모두 참이어야 참이다.# not x x가 거짓이면 참이다.empty = ''if not empty == '': print('no')else: print('yes')if empty == 'man': print('man')else: if 'woman': # 파이썬에서 문자열은 비어 있지 않기 때문에 **참(True)**으로 평가 print('woman') else: print('empty')# in, not in (문자열, 리스트, 튜플)a = 1 in [1, 2, 3]a =.. 2024. 12. 26.