python
-
conda 가상환경을 새로운 가상환경에서 설치python 2022. 1. 20. 11:23
1. 가상환경의 pip list를 출력한다 ( 아래의 코드처럼 진행해야 깔끔한 requirements.txt를 출력할 수 있음) 1 pip list --format=freeze > requirements.txt cs 2. conda 의 environments를 yml 형식으로 출력한다 (아래의 코드로 진행) 1 conda env export > conda_environment.yml --no-builds cs 3. conda_environment.yml를 연다 3.1 제일 위에 name 을 가상환경 이름으로 수정 3.2 제일 밑에 prefix부분의 경로 마지막 부분을 새로 만든 가상환경의 이름으로 수정 3.3 새로운 가상환경에 세팅되어야 할 conda list를 만든다고 생각하면 됨 4. 설치 1 con..
-
[python] index와 find의 차이python 2021. 7. 8. 13:26
Difference Between find( ) and index( ) in Python - GeeksforGeeks A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions. www.geeksforgeeks.org 공통점 : 기준이 되는 substring에 맞는 첫 번째 index를 return한다 차이점 index : 해당하는 substring이 없으면 Error를 출력 1 2 3 4 ..
-
[Python] Multiprocessing 예제 Codepython 2021. 7. 1. 13:08
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 from multiprocessing import Process import time import os start_time=time.time() def count(cnt): proc=os.getpid() for i in range(cnt): print(f"Process ID : {proc} -- {i}") def count1(cnt): proc=os.getpid() for i in range(cnt): print(f"Process ID : {proc} -- {i..
-
[pip] requirements.txt 추출할 때 version대신 다른 reference가 생기는 bugpython 2021. 6. 29. 12:37
pip freeze creates some weird path instead of the package version I am working on developing a python package. I use pip freeze > requirements.txt to add the required package into the requirement.txt file. However, I realized that some of the packages, instead... stackoverflow.com 결론 : 아래의 코드로 해결가능 pip list --format=freeze > requirements.txt
-
[Python] 지구의 타원을 고려한 거리계산 Package haversinepython 2021. 5. 20. 12:04
1. Package Install 1 $ pip install haversine cs 2. Calculate the distance between Lyon and Paris 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 from haversine import haversine, Unit lyon = (45.7597, 4.8422) # (lat, lon) paris = (48.8567, 2.3508) haversine(lyon, paris) >> 392.2172595594006 # in kilometers haversine(lyon, paris, unit=Unit.MILES) >> 243.71201856934454 # in miles # you can also use..
-
[Python] Command창에서 Argument 추가 argparsepython 2021. 4. 9. 15:38
작업을 하다보면 커맨드 창에서 함수를 구동시킬 때 매개변수를 조정하고 싶은 경우가 있다. 이럴 때 사용할 수 있는 Python 내장 라이브러리 argparse를 사용할 수 있다. argparse의 기본적인 사용법에 대해 알아본다. Argparse 자습서 — Python 3.9.4 문서 Argparse 자습서 저자 Tshepang Lekhonkhobe 이 자습서는 파이썬 표준 라이브러리에서 권장하는 명령행 파싱 모듈인 argparse 에 대한 소개입니다. 참고 같은 작업을 수행하는 다른 두 모듈이 있습니다, geto docs.python.org VSCode에서 시작날짜와 마지막날짜를 입력하면 그 사이의 날짜들을 반환하는 함수를 .py파일 안에 만들었다. 만약 이 .py파일을 실행시킬 때마다 시작 날짜와 마..
-
[Python] Python 자동화 Schedule 모듈python 2021. 1. 22. 11:53
매일 혹은 매주 함수를 수행하고 결과값을 저장하거나 DB에 적재하는 등의 일을 할 때가 있다. 그 때 사용할 수 있는 것이 Python의 자동화 모듈 Schedule이다. 별도의 install이 필요하다. pip를 활용하여 install을 진행한다. schedule.readthedocs.io/en/stable/ schedule — schedule 0.4.0 documentation schedule.readthedocs.io 1. 초, 분, 시간 단위로 실행 import schedule import time def geeks(): print("Shaurya says Geeksforgeeks") def bedtime(): print("It is bed time go rest") def good_luck():..
-
[django] install 및 projectapp 생성python/django 2020. 12. 31. 17:18
※ Django 버전과 Python 버전 호환관련 docs.djangoproject.com/ko/3.1/faq/install/#faq-python-version-support 자주묻는 질문: 설치 | Django 문서 | Django Django The web framework for perfectionists with deadlines. Overview Download Documentation News Community Code Issues About ♥ Donate docs.djangoproject.com ※ Django 한글문서 홈페이지 docs.djangoproject.com/ko/3.1/ Django 문서 | Django 문서 | Django Django The web framework for ..