Python/Python

[Python] 다양한 문자 포멧팅 방법 [ 기준 : Python 2.7 ] 1. var = '%(foo)s %(foo)s %(foo)s' % { 'foo': 'look_at_me_three_times' } 2. var = '{0} {0} {0}'.format('look_at_meeee') 3. var = '{foo} {foo} {foo}'.format(foo = 'python you so crazy') [참고] https://stackoverflow.com/questions/6982949/output-formatting-in-python-replacing-several-s-with-the-same-variable
[Python] python2, python3 둘다 설치하는 방법 (windows) 현재 Python 2.7을 쓰고 있지만, 점차 Python2.X대에 대한 지원이 없어져 가고..... 아직 Python2.X 로 개발된 프로젝트들이 많기에 두 버전 모두 한 PC에서 사용할 수 있도록 하는 방법입니다. Python2.X, Python3.X를 설치합니다. 👉 https://www.python.org/downloads/ 설치 경로는 C 밑에 설치해 줍니다. Python2.7을 설치한다면 C:\Python27경로, Python3.7을 설치한다면 C:\Python37등 C밑에 설치해 주면 후에 Path 설정에 편리해집니다. python2와 python3 모두 python.exe파일을 실행하기 때문에 충돌이 납니다..
[Python] 순열과 조합 하나의 리스트에서 모든 조합을 계산하는 방법 1. 순열 itertools.permutations(iterable[, r]) https://www.hackerrank.com/challenges/itertools-permutations/problem iterable: iterable한 값 r: 몇개 씩 묶을 것인지, (미 입력 -> iterable 전체 길이) >>> from itertools import permutations >>> print list(permutations(['1','2','3'])) [('1', '2', '3'), ('1', '3', '2'), ('2', '1', '3'), ('2', '3', '1'), ('3', '1', '2'), ('3', '2', '..
[Python] faker 라이브러리 faker https://faker.readthedocs.io/en/master/index.html 가짜 더미 데이터를 만들어주는 라이브러리. database나 xml등과 같은 곳에 테스트를 위한 더미 데이터를 만드는데 사용할 수 있다. Faker is a Python package that generates fake data for you. Whether you need to bootstrap your database, create good-looking XML documents, fill-in your persistence to stress test it, or anonymize data taken from a production service, Faker is ..
[Python] 설치된 패키지 목록 requirements.txt 만들기 가상환경(venv)이나 현재 python에 pip으로 설치된 패키지 목록에 대한 정보를 requirements.txt 로 만들기 위해서는 freeze 명령어를 사용하면 된다. $ pip freeze > requirements.txt requirements.txt의 패키지들을 모두 설치하기 위해서는 아래 명령어를 이용하면 된다. $ pip install -r requirements.txt [참고] https://docs.python.org/ko/3/tutorial/venv.html
[Python][ERROR] SSL: CERTIFICATE_VERIFY_FAILED 에러 urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581) 임시 context를 만들어 ssl 인증을 우회할 수 있다. import ssl ssl._create_default_https_context = ssl._create_unverified_context [참고] https://stackoverflow.com/questions/27835619/urllib-and-ssl-certificate-verify-failed-error
S0PH1A
'Python/Python' 카테고리의 글 목록