본문 바로가기

프로그래밍63

유용한 Visual Studio Code 단축키 Show Command Palette Ctrl + Shift + P, F1 Go To Definition F12 Go Back Alt + ← Go Forward Alt + → Show Terminal Ctrl + ' (quote) New Terminal Ctrl + Shift + ' (quote) Toggle Line Comment Ctrl + / Toggle Block Comment Shift + Alt + A 2020. 12. 28.
What is the purpose of a question mark after a type (for example: int? myVariable)? tinyurl.com/y3eoyo5h What is the purpose of a question mark after a type (for example: int? myVariable)? Typically the main use of the question mark is for the conditional, x ? "yes" : "no". But I have seen another use for it but can't find an explanation of this use of the ? operator, for example. ... stackoverflow.com It means that the value type in question is a nullable type 2020. 12. 9.
git 로그를 그래픽하게 매번 찾기 귀찮은 작업이라 메모! git config --global -e 아래 내용 추가 [alias] lg1 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(re.. 2020. 12. 1.
우분투18.04에서 gunicorn으로 flask앱 실행 서버 설치 후 패키지 정보 업데이트와 업그레이드 진행 sudo apt update && sudo apt upgrade -y 가상환경을 위한 패키지 준비 sudo apt install python3-pip python3-dev build-essential libssl-dev libffi-dev python3-setuptools sudo apt install python3-venv 플라스크 프로젝트 다운로드 git clone https://github.com//.git 프로젝트에 가상환경 생성 cd / python3 -m venv venv source venv/bin/activate (venv)pip install wheel (venv)pip install gunicorn flask 하단에 호스트 속성 추가.. 2020. 9. 24.
파이썬에 mariadb 패키지 가져오기 sudo apt update # 저장소 추가 sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8 sudo add-apt-repository "deb [arch=amd64,arm64,ppc64el] http://mariadb.mirror.liquidtelecom.com/repo/10.4/ubuntu $(lsb_release -cs) main" sudo apt update # 개발환경 패키지 설치 sudo apt install -y build-essential libssl-dev libffi-dev python3-dev # 의존성 패키지 설치 sudo apt install -y libmariadb3 .. 2020. 9. 14.
_와 __의 차이 아래 링크에는 파이썬에서 _의 사용에 대해 잘 설명되어 있다. 1. 인터프리터에서 사용되는 경우 2. 값을 무시하고 싶은 경우 3. 특별한 의미의 네이밍을 하는 경우 4. 국제화(i18n)/지역화(l10n) 함수로 사용되는 경우 5. 숫자 리터럴값의 자릿수 구분을 위한 구분자로써 사용할 때 꼭 한 번 방문해 읽어 보시길... mingrammer.com/underscore-in-python/ 2020. 8. 27.
모스부호로 통신 네트워크 프로그래밍 클라이언트 서버 1:1 네트워크 프로그래밍입니다. 서버를 실행하면 memo.txt를 읽어 모스 부호로 변환합니다. 클라이언트가 접속하면 변환한 모스 부호를 보내주고 클라이언트는 이를 받아 다시 문자로 변환하여 rcv_memo.txt로 저장하는 코드입니다. server.py """ 서버와 클라이언트 연결 """ from socket import * import module myip = '127.0.0.1' # 서버 IP 주소 myport = 62580 # 클라이언트가 최초 연결할 포트 with open('memo.txt', 'r', encoding='utf-8') as f: message = f.readline() # KOREA WELCOME mos_msg = module.alp2mos(message) #.. 2020. 8. 26.
빅텍스트 출력하기 클래스로 구현한 빅텍스트입니다. class BigText: T1 = "*"*5 T2 = "* *" T3 = "{0:>5}".format("*") T4 = "{0: 2020. 8. 21.
정규식을 이용해 html 태그 제거하기 정규식을 이용해 html의 태그를 제거합니다. 예를 들어 아래 html에서 '샘플2'를 추축하게 됩니다. 샘플2 주의. python3에서 사용합니다. python2에서는 UnicodeDecodeError가 발생하게 됩니다. import re pattern = re.compile(u']*?\/?>', re.DOTALL | re.MULTILINE | re.IGNORECASE | re.UNICODE) ht1 = '샘플' print(pattern.sub(u"",ht)) '샘플' ht2 = '샘플' print(pattern.sub(u"",ht2)) '샘플' ht3 = '샘플2' print(pattern.sub(u"",ht3)) '샘플2' 2020. 8. 21.