일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- YOLO
- VS Code
- C
- windows forms
- C++
- Selenium
- 프로그래머스
- Numpy
- 기타 연주
- C#
- 오류
- Visual Studio
- JSON
- OpenCV
- pandas
- mysql
- label
- Python
- 채보
- Linux
- pip
- pytorch
- error
- Docker
- nvidia-smi
- 핑거스타일
- ubuntu
- 컨테이너
- SSH
- paramiko
- Today
- Total
목록Python (117)
기계는 거짓말하지 않는다
Module 'ffmpeg' has no attribute 'probe' Python에서 ffprobe를 사용할 때 이런 오류를 보는 경우가 있다. 기본적으로 ffmpeg는 별개로 설치되어 있어야 한다. 그 후 Python의 pip를 이용하여 명령어를 사용할 수 있도록 module을 설치한다. pip list를 확인하여 ffmpeg-python이 설치되어 있는지 확인한다. python-ffmpeg가 아니다. pip install ffmpeg-python
traceback — 스택 트레이스백 인쇄와 조회 — Python 3.7.16 문서 traceback — 스택 트레이스백 인쇄와 조회 — Python 3.7.16 문서 traceback — 스택 트레이스백 인쇄와 조회 소스 코드: Lib/traceback.py 이 모듈은 파이썬 프로그램의 스택 트레이스를 추출, 포맷 및 인쇄하는 표준 인터페이스를 제공합니다. 스택 트레이스를 인쇄할 docs.python.org 아래는 stacktrace 출력의 간단한 예이다. import traceback try: a = 1 / 0 except ZeroDivisionError as e: # 기본 에러 메시지 print("Error Msg:", str(e)) print("-" * 50) print("-- Stack Trac..
pymysql connect의 cursor sql 실행 후 변경된 DB 값을 commit 함수를 호출해도 인식하지 못하는 경우가 있다. commit 위치가 잘못되었을 수 있고 자동 커밋을 원하면 매번 connect를 새로하는 대신 connect 매개변수에 autocommit=True를 추가한다. conn = pymysql.connect(host='localhost', port=3306, user=user, passwd=passwd, db=db, charset='utf8', autocommit=True) 참고 Python MySQL not refreshing - Stack Overflow Python MySQL not refreshing I have two programs: One that fill and..

프로그래머스 - 우박수열 정적분 문제입니다. 자연수 k와 범위(ranges)가 주어지면 해당 범위 넓이를 리턴하는 문제입니다. 범위가 같거나 유효하지 않은 구간이 주어지는 경우도 있습니다. 문제의 콜라츠 추측대로 값들을 구하고, x축 길이가 1인 구간들의 넓이를 구합니다.(위 예시는 다섯 구간) 그 후 주어진 범위(ranges)의 넓이 합들을 리턴합니다. def solution(k, ranges): answer = [] point_list = [] point_list.append(k) # 콜라츠 추측 계산 while k != 1: if k % 2 == 0: k = int(k / 2) else: k = (k * 3) + 1 point_list.append(k) range_area = [] # 구역 넓이 계..
Python에서 Paramiko를 이용한 간략한 SSH Client 원격 연결 방법이다. 설치 pip install paramiko 사용 Paramiko Docs Client — Paramiko documentation Client SSH client & key policies class paramiko.client.SSHClient A high-level representation of a session with an SSH server. This class wraps Transport, Channel, and SFTPClient to take care of most aspects of authenticating and opening channels. A typical docs.paramiko.org ..
Python의 list 복사를 예시로 들 수 있다. 얕은 복사(Shallow Copy)는 list 뿐 아니라 mutable 객체 모두 문제가 된다. Docs: Python copy module copy — Shallow and deep copy operations Source code: Lib/copy.py Assignment statements in Python do not copy objects, they create bindings between a target and an object. For collections that are mutable or contain mutable items, a copy ... docs.python.org List 초기화 # 2차원 list 10행 5열 생성, 초기..
Python 객체를 파일로 저장할 때 기본 내장된 pickle 모듈을 사용할 수 있다. Python pickle module docs pickle — Python object serialization Source code: Lib/pickle.py The pickle module implements binary protocols for serializing and de-serializing a Python object structure. “Pickling” is the process whereby a Python object hierarchy is... docs.python.org 간단한 사용법은 아래와 같다. import pickle class TempClass(object): def __init__(..
Python에서 변수 타입을 선언할 수 있는 방법은 다음과 같다. 타입이 맞지 않아도 오류를 발생시키지 않지만 문자열 타입을 가정하고 문자열 함수를 작성 한 코드에 다른 타입을 받게 되면 오류가 발생한다. 함수 매개변수 타입 선언, return 타입 선언 def print_string(string: str, new_line: bool) -> bool: try: print(string, end="" if new_line == False else "\n") return True except Exception: return False print_string("AAAAA", new_line=True) 변수 타입 선언 my_string: str = None