일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
- evaluation
- numpy
- enV
- Laravel
- 책갈피
- Database
- PostgreSQL
- Paper
- AI
- DB
- list
- Python
- format
- Package
- docker
- git
- Linux
- file
- pytorch
- GitLab
- Flask
- Converting
- LLM
- Mac
- judge
- Container
- KAKAO
- Windows
- pandas
- TORCH
- Today
- Total
목록Develope/Python (32)
Daily Develope
Pickle이란? Python의 객체(Object)를 binary 파일로 serializing 하거나 반대로 binray 파일로부터 de-serializing 하기 위한 프로토콜이 구현된 라이브러리. 흔히 pickling, flattening, marshalling 등으로 일컫는다. 장점? Python 객체를 바로 파일로 쓰거나 읽을 수 있다. Binary(또는 Bytes) 형태로 데이터를 다루기 때문에 읽기/쓰기 속도가 빠르다. 읽기/쓰기 예시코드 import pickle import os my_filepath = "target/file/path/filename.bin" my_data = ['target', 'data'] if os.path.isfile(my_filepath): ### 읽기 with o..
환경Python 3.9.7- modules : psycopg2Postgresql (Container, version:alpine3.18)- host : 127.0.0.1- port : 5432- database : mydb- 컨테이너 배포 샘플코드Connection Classimport psycopg2import loggingclass DBBaseController: def __init__(self, host:str="127.0.0.1", port:int=5432) -> None: self.__connect(host=host, port=port) def __connect(self, host:str="127.0.0.1", port:int=5432): try: ..
방법 1. 내장 property method 클래스의 속성값에 대한 getter, setter, destructor 동작을 method로 정의하고, 내장함수인 property를 사용해 해당하는 속성과 연결시켜 사용. 샘플코드 # Python program showing a use of property() function class Geeks: def __init__(self): self._age = 0 # function to get value of _age def get_age(self): print("getter method called") return self._age # function to set value of _age def set_age(self, a): print("setter metho..
리스트 (List) List의 Item 한 줄씩 출력 my_list = ["line1", "line2", "line3"] print(f"{my_list}", sep="\n")List 간단한 명령 한 줄로 처리 ### 예) a 값이 None 인 경우를 제외하고 덧셈 값 반환 sample = [[1, 2], [3, 4], [None, 6]] sample = [a+b for a, b in sample if a != None] >> print(sample) [3, 7]List 의 index 및 값 순차출력 t_list = [1, 5, 7, 33, 39, 52] for tup in enumerate(t): print(tup) ### output (0, 1) (1, 5) (2, 7) (3, 33) (4, 39) (..