프로그래밍/Python

    [파이썬] 유튜브 영상 다운로드하고 mp4, mp3로 변환하기(pytube, ffmpeg)

    from pytube import YouTube #유튜브영상을 다운로드하기 위한 모듈 import os.path #경로를 설정하기 위한 모듈 import ffmpeg #미디어를 변환하기 위한 모듈 from getpass import getuser #기본 경로를 다운로드 폴더로 지정하기 위한 모듈 class Download: ''' 파일을 변환하기 위해선 ffmpeg란 프로그램을 별도로 설치해 컴퓨터 환경변수 설정을 마쳐야 함. ''' def __init__(self, link): #link 인자는 gui에서 입력된 값을 받을 때 사용 #컴퓨터 이용자명을 받아서 다운로드폴더를 기본폴더로 지정 self.parent_dir = f"C:\\Users\\{getuser()}\\Downloads" self.yt =..

    [파이썬] str과 repr

    __str__ str(), format(), print()에 의해 호출되어 객체의 인쇄 가능한 비형식적(informal) 문자열 표현을 반환한다. __repr__ repr()에 의해 호출되어 객체의 공식적(formal)인 문자열 표현을 반환한다. 개체를 다시 만드는 데 사용할 수 있는 유효한 파이썬 표현을 만든다. class Ex: pass b = Ex() print(repr(b)) # 따로 형태가 정의되지 않으면 클래스 이름과 변수가 있는 메모리 주소를 기본형으로 출력한다. (By default, it prints the module the object it's from, the class name, and the hexadecimal representation of its location in mem..