본문 바로가기

Language

[ReactJS] create-react-app의 실행 포트 변경 ReactJS로 프로젝트를 시작하면, 보통 create-react-app을 사용합니다. 개발을 하고 시작을 하려면 다음과 같은 명령을 실행하게 됩니다. yarn run start 그러면 http://localhost:3000으로 페이지가 열리게 됩니다. 실행 Port 변경하기 Start Script 수정하기 실제 start 스크립트를 보면 다음과 같이 포트를 설정하고 있습니다. const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3000; 따라서 package.json 파일에서 scripts 부분의 start에 PORT 환경변수 설정을 추가합니다. 여기서는 Windows환경에서 9090포트로 변경하겠습니다. { ... "scripts": { "start": .. 더보기
[Python 3.8] TypeError: 'type' object is not subscriptable 문제점 Python 3.8을 사용중인데 typing을 활용하여 타입에 대한 힌트를 지정할 때 다음과 같은 오류가 발생합니다. Traceback (most recent call last): File "main.py", line 13, in def test(num_list: list[int]) -> list[int]: TypeError: 'type' object is not subscriptable 원인 typing 힌트에서 제너릭에 대한 지원은 Python 3.9부터 시작됩니다. 관련 문서는 PEP 585 (https://peps.python.org/pep-0585/) 에 있습니다. 해결방법 1 Python에 대한 버전업이 가능하다면 3.9 이상으로 올리면 됩니다. 해결방법 2 Python에 대한 버전업이.. 더보기
[Python] 숫자를 문자열로 변경하기 (int to string, float to string) 원하는 것 파이썬에서 숫자를 문자로 변경하고자 합니다. 다른 문자열과 합치거나, 문자열 타입으로 저장해야할 때 필요합니다. 방법 1 str() 함수를 사용합니다. int_str = str(10) # 10 float_str = str(10.0) # 10.0 방법 2 f-string 을 활용합니다. num: int = 10 int_str = f"{num}" # 10 float_num: float = 10.0 float_str= f"{float_num}" # 10.0 방법 3 str.format() 을 활용합니다. num: int = 10 int_str = "{}".format(num) # 10 float_num: float = 10.0 float_str= "{}".format(float_num) # 10.0 더보기
[Python] 문자열을 연산자로 사용하기 원하는 것 문자열로 연산식을 받고 이것에 대한 계산결과를 보고 싶습니다. 예로 "3 + 2" 를 받으면 5이라는 결과를 받고 싶습니다. 해결방법 단순하게 if를 사용해도 eval 을 사용해도 됩니다. 그런데 eval의 경우에는 원하는 용도 이외에도 처리해버리기 때문에 위험합니다. 다른 방법으로 python에서는 operator 라는 패키지를 제공합니다. 이것을 활용하여 연산처리를 진행하면 됩니다. import operator ops = { "+": operator.add, "-": operator.sub, "*": operator.mul, "/": operator.truediv } input = "3 + 2" split_input = input.split(" ") print(ops[input[1]](in.. 더보기
[Selenium Python] 'WebDriver' object has no attribute 'find_elements_by_class_name' 문제점 Chrome 115 버전 이슈를 해결하기 위해 Selenium을 3버전대에서 4버전으로 올린 뒤 WebDriver에서 find_elements_by_class_name 속성을 못찾는 현상이 발생했습니다. ... AttributeError: 'WebDriver' object has no attribute 'find_elements_by_class_name' 원인 Selenium이 3.x에서 4.x로 변경되면서 find_element, find_elements로 통합되었습니다. 기존 find_element(s)_by 함수는 deprecated 되었습니다. 해결방법 아래와 같이 함수를 변경하면 됩니다. web_driver.find_element(By.ID, "id") web_driver.find_ele.. 더보기
[Selenium Python] chrome 115 버전 드라이버 오류 문제점 Selenium으로 UI테스트 코드를 사용중 크롬버전이 115로 업데이트가 되면서 Chrome Driver 검색이 안되는 오류가 발생함. ... File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/common/driver_finder.py", line 44, in get_path raise NoSuchDriverException(f"Unable to locate or obtain driver for {options.capabilities['browserName']}") selenium.common.exceptions.NoSuchDriverException: Message: Unable to locate or obtain driver f.. 더보기
[Vue.js] Tags with side effect (script and style) are ignored in client component templates. 현상 vue.js의 컴포넌트에서 script나 style 태그를 사용한 뒤 실행하면 다음과 같은 오류가 발생합니다. Internal server error: Tags with side effect ( and ) are ignored in client component templates. 해결방법 필요한 스크립트나 스타일을 전역으로 설정하면 되지만, 여기서는 다음 방법으로 컴포넌트내 삽입할 수 있습니다. script를 component is="script" 로 변경하면 됩니다. 기존 스크립트 변경 스크립트 더보기
[Java] Queue 자료형 Queue 란? Queue는 선입선출(FIFO, First In First Out)방식의 자료형입니다. 먼저 입력되는 데이터가 먼저 나가는 구조로 되어있습니다. 일반적인 줄서기와 동일하다고 보시면 됩니다. Queue 종류 // 기본 인터페이스 import java.util.Queue; // LinkedList import java.util.LinkedList; // PriorityQueue import java.util.PriorityQueue; Java에서 Queue는 Interface로 정의되어있습니다. 기본적으로는 LinkedList를 활용하여 Queue를 사용하고 있습니다. 만약 내부적 정렬이 필요한 경우에는 PriorityQueue를 사용하고 있습니다. (예 : Queue에 입력된 데이터를 내림.. 더보기