본문 바로가기
728x90
반응형

파이썬68

[Python] ImportError: Missing optional dependency 'xlrd'. Install xlrd >= 2.0.1 for xls Excel support Use pip or conda to install xlrd. 에러 해결 방법 !! [Python] ImportError: Missing optional dependency 'xlrd'. Install xlrd >= 2.0.1 for xls Excel support Use pip or conda to install xlrd. 에러 해결 방법 !! 위 에러가 발생하였을 경우 xlrd패키지를 설치 해주면 된다 ! # pip 사용 할 경우 pip install xlrd # conda 사용 할 경우 conda install -c anaconda xlrd 2023. 11. 20.
[Python] 파이썬으로 주사위 게임 만드는 방법 !! [Python] 파이썬으로 주사위 게임 만드는 방법 !! 코드가 간단하니 아래 코드를 응용해서 사용하시면 됩니다 :) import random class DiceGame: def __init__(self): self.player_wins = 0 self.computer_wins = 0 self.draws = 0 def roll_dice(self): return random.randint(1, 6) def play_round(self): player_roll = self.roll_dice() computer_roll = self.roll_dice() print(f"플레이어의 주사위: {player_roll}") print(f"컴퓨터의 주사위: {computer_roll}") if player_roll > .. 2023. 10. 13.
[Python] 셀레니움(selenium)에서 webdriver로 자신한테 맞는 크롬 드라이버 찾는 방법 !! (+ 다른 브라우저 드라이버 사용방법) [Python] 셀레니움(selenium)에서 webdriver로 자신한테 맞는 크롬 드라이버 찾는 방법 !! (+ 다른 브라우저 드라이버 사용방법) 최상단에 공통 라이브러리 임포트 하시고, 아래 브라우저에 맞게 사용하시면 됩니다 :) 공통 라이브러리 from selenium import webdriver from selenium.webdriver.chrome.service import Service 크롬 from webdriver_manager.chrome import ChromeDriverManager driver = webdriver.Chrome(service=Service(ChromeDriverManager().install())) 파이어폭스 from webdriver_manager.firefox.. 2023. 7. 28.
[Python] 파이썬으로 문자열 속에서 특정 단어 찾는 방법 !! [Python] 파이썬으로 문자열 속에서 특정 단어 찾는 방법 !! 많은 문자열 속에서 특정 단어를 찾는 방법 입니다 !! 예제코드 string = '안녕하세요 반갑습니다 안녕' print(string.find('안녕')) # 특정 단어의 첫번째 위치 print(string.find('하이')) # 단어가 없다면 -1을 리턴 print(string.rfind('안녕')) # 특정 단어의 마지막 위치 결과값 0 -1 12 2023. 7. 18.
[AWS] 파이썬 패키지 설치 에러 Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. 해결방법 !! [AWS] 파이썬 패키지 설치 에러 Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. 해결방법 !! aws ec2에서 파이썬 requirements.txt 설치 중 mysqlclient 설치하는 과정에서 위와 같은 에러가 발생하였다. 검색해보니 mysqlclient 설치 전에 필요한 의존성 라이브러리들이 필요했고, 설치하니 바로 해결 되었다. 해결 명령어 $ sudo apt install python3-dev default-libmysqlclient-dev build-essential 2023. 7. 3.
[Python] 현재 요일,시간 한글로 표현하는 방법 !! (시간형식 포맷팅) [Python] 현재 요일,시간 한글로 표현하는 방법 !! (시간형식 포맷팅) 파이썬에서 현재 요일,시간 포맷팅하여 한글로 보여주는 코드입니다 :) 예제코드 import datetime current_time = datetime.datetime.now() weekday_dict = { 0: '월요일', 1: '화요일', 2: '수요일', 3: '목요일', 4: '금요일', 5: '토요일', 6: '일요일' } ampm_dict = { 'AM': '오전', 'PM': '오후' } formatted_time = current_time.strftime("%Y년 %m월 %d일") + ' ' + weekday_dict[current_time.weekday()] + ' ' + ampm_dict[current_tim.. 2023. 6. 19.
[Python] 리스트 데이터 문자열로 바꾸는 방법 !! (list to str) [Python] 리스트 데이터 문자열로 바꾸는 방법 !! (list to str) 파이썬에서 리스트로 되어있는 데이터를 문자열로 바꾸는 방법입니다 ! 콤마(,) 를 유지한체 하는 방법도 있습니다 :) 예제코드 listData = ['1', '2', '3', '4', '5'] strData = ''.join(listData) strData2 = ','.join(listData) print(strData) # 12345 print(strData2) # 1,2,3,4,5 2023. 5. 25.
[PyCharm] 파이참에서 commit 취소하는 방법 (undo commit) [PyCharm] 파이참에서 commit 취소하는 방법 (undo commit) 커밋 내용이 틀렸다거나, 다른 파일까지 커밋을 했을경우 취소하는 방법입니다 ! 단, 푸쉬하기전 커밋만 가능합니다 ㅎ Alt+9 눌러 커밋 log를 실행시키고 취소할 커밋에 우클릭 후 Undo Commit 클릭하시면 끝! 입니다 원하는 Changelist 선택 후 OK! 2023. 5. 23.
[Python] 셀레니움(Selenium) 실행되는 크롬 창 크기 조절하는 방법 !! [Python] 셀레니움(Selenium) 실행되는 크롬 창 크기 조절하는 방법 !! 아래 코드를 사용하시면 셀레니움으로 실행 될 때 크롬 창크기를 조절 하실 수 있습니다 !! 예제코드 options = webdriver.ChromeOptions() options.add_argument('window-size=넓이(width),높이(height)') driver = webdriver.Chrome(크롬드라이버 경로,options=options) 2023. 5. 22.
728x90
반응형