일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- X윈도우
- Mac
- Entity
- Entity Set
- Operator
- 백준
- selenium
- systemd
- BFS
- 리눅스
- 리눅스 마스터 1급
- literal
- External Scheme
- Binary Search
- 자바
- Class
- spring
- Reference Type
- dbms
- Physical Scheme
- Inheritance
- Polymolphism
- Unity
- Java
- descriptive statistics
- 셀레니움
- OOP
- X.org
- preprocessing
- python
- Today
- Total
목록Programming Language (44)
Byeol Lo
자바에서는 수많은 인자들을 받도록 하게 하는 기능을 제공하는데 바로 가변인자이다. public class HelloWorld { void printing(String...words) { System.out.println("Start Print"); for(String s : words) { System.out.println(s); } } public static void main(String args[]) { HelloWorld hello = new HelloWorld(); hello.printing("hi", "my", "name", "is", "hello"); } }
인스턴스 변수 : 객체에서 인스턴스화 될 때 해당 인스턴스만의 변수 클래스 변수 : 클래스에 속한 모든 인스턴스에서 공통적으로 사용할 수 있는 변수 public class Human { //인스턴스 변수 int height = 100; //클래스 변수 static boolean brain = True; } 클래스 내부에서 만드는 모든 변수들을 멤버 변수라고 한다. (메소드 안에서는 아님)
클래스가 인스턴스화 될때 실행되는 메서드이다. 다음 예제를 통해 익힐 수 있다. public class Test { String name; // 생성자 메서드 // 클래스가 인스턴스화 할때 실행되는 메서드 Test() { System.out.println("인스턴스화 완료"); } public static void main(String args[]) { Test test = new Test(); System.out.println("hihi"); } }
직사각형이 다음과 같이 주어진다고 하자. (x1, y1, x2, y2) 좌표계는 1부터 50까지 있다고 치면, 많은 직사각형들에 대해 외곽을 다음 로직을 통해 list로 구현 할 수 있다. def draw(rectangles) : map = [[9]*50 for _ in range(50)] for rect in rectangles : for x in range(rect[0], rect[2]+1) : for y in range(rect[1], rect[3]+1) : if rect[0] < x < rect[2] and rect[1] < y < rect[3] : map[y][x] = 0 elif map[y][x] : map[y][x] = 1 for i in map : print(*i) if __name__ =..
reduce 함수는 리스트 들에 대해 어떠한 연산을 누적하여 수행하고 싶을때 쓸 수 있는 함수이다. 예를 들어 [1,3,5,67,4,5]라는 리스트를 다 더하고 싶다면 다음과 같이 적으면 된다. from functools import reduce lst = [1,3,5,67,4,5] print(reduce(lambda x, y: x+y, lst)) # 85 lambda 식이 아니더라도 사용자 정의 함수로 다가갈 수 있다. 파이썬 3.9에서는 @functools.cache라는 함수가 있는데 데코레이터로 쓴다면 값들을 저장하여 다시 그 연산을 수행할때, 연산을 안하고 바로 호출 할 수 있도록 한다. 이를 메모이제이션이라고 말하는데, 동일한 계산의 반복 수행을 제거하여 최적화하는 기술이다. 계산이 무거울 때 ..
from operator import itemgetter, attrgetter student_tuples = [ ('수학', 105), ('영어', 140), ('과학', 133), ('국어', 100) ] class Student : def __init__(self, name, grade, age) : self.name = name self.grade = grade self.age = age def __repr__(self) : return repr((self.name, self.grade, self.age)) student_objects = [ Student('홍길동', "A+", 22), Student('아이유', "A0", 20), Student('김구', "A+", 21), Student('야스..
mac에서 가끔 python을 설치하거나 업데이트를 하면 다음과 같은 오류가 뜰 수 있다. zsh: command not found: python 해당 오류는 zsh에서 python 이라는 명령어를 찾을 수 없다는 소리이다. 다음을 통해 조정하자. VSC는 해당 파일에 settings.json을 접근하여 vsc 기본 세팅값들을 만질 수 있다. cd ~/Library/Application\ Support/Code/User/ zsh에서 python을 실행할때 쓰는 명령어를 (명령어) 부분에 쓰면 되겠다. "code-runner.excutorMap" : { "python": "(명령어)", ... } 아마 "python3" 이거나 "python" 으로 설정하면 거의 다 될 것이다.
Numpy 는 행렬 연산에 특화된 자료구조와 연산을 지원하는 라이브러리이다. pip install pip --upgrade pip install numpy # pip install numpy --upgrade # pip uninstall numpy 위의 pipeline 명령어들을 통해 numpy를 설치, 삭제, 업데이트가 가능하다. import numpy as np arr1 = np.array([[1,2,3,4,5],[2,3,4,5,6],[3,4,5,6,7],[4,5,6,7,8],[5,6,7,8,9]]) arr2 = np.array([1,2,3,4,5]) arr3 = 1 print(arr1 + arr2) print("==============") print(arr2 + arr3) print("======..
다음 함수를 가져와서 쓰면 된다. from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC from selelnium import webdriver url = 'https://www.naver.com/' options = webdriver.ChromeOptions() options.add_argument("headless") driver = webdriver.Chrome(options=options) driver.get(url) WebDriverWait(driver, 2..
다음 options을 세팅하자! from selenium import webdriver from selenium.webdriver.chrome.options import Options import chromedriver_autoinstaller chromedriver_autoinstaller.install("./") chrome_options = Options() chrome_options.add_argument('--headless') chrome_options.add_argument('--log-level=3') # 브라우저 로그 레벨을 낮춤 chrome_options.add_argument('--disable-loging') # 로그를 남기지 않음 driver = webdriver.Chrome(ch..