본문 바로가기

반응형

스크립트

[스크립트] jq 패키지 설치하는 스크립트 jq 패키지 설치하는 스크립트 jqinstall.sh 스크립트 작성 vim jq-install.sh #!/bin/bash # Check if jq is already installed if command -v jq &> /dev/null; then echo "jq is already installed." else # Check package manager and install jq if command -v apt-get &> /dev/null; then sudo apt-get update sudo apt-get install -y jq elif command -v yum &> /dev/null; then sudo yum update sudo yum install -y jq else echo "Unable.. 더보기
[스크립트] What Is My IP?(myip) What Is My IP? bind utilities centos yum install -y bind-utils ubuntu apt-get install -y bind9-dnsutils Public IP Address dig @resolver1.opendns.com myip.opendns.com +short Private IP Address ip route get 1.2.3.4 | awk '{ print $7 }' | egrep -v '^$' 더보기
[스크립트] python beautifulsoup4 python beautifulsoup4 beautifulsoup parser(파서) Parser Typical usage Advantages Disadvantages Python’s html.parser BeautifulSoup(markup, "html.parser") - Batteries included - Decent speed - Lenient (As of Python 3.2) - Not as fast as lxml, less lenient than html5lib. lxml’s HTML parser BeautifulSoup(markup, "lxml") - Very fast - Lenient - External C dependency lxml’s XML parser BeautifulSoup(mark.. 더보기
[코딩테스트 입문] n의 배수 고르기 n의 배수 고르기 1안) solution.py def solution(n, numlist): answer = [] for num in numlist: if (num % n == 0): answer.append(num) return answer 2안) solution.py def solution(n, numlist): answer = [] answer = list(filter(lambda num: num % n == 0, numlist)) return answer 3안) solution.py def solution(n, numlist): answer = [] answer = [num for num in numlist if num % n == 0] return answer 출처 - 프로그래머스(코딩테스트 연.. 더보기
[코딩테스트 입문] 자릿수 더하기 자릿수 더하기 1안) solution.py def solution(n): answer = 0 num_list = [] for i in str(n): num_list.append(int(i)) answer = sum(num_list) return answer 2안) solution.py def solution(n): answer = 0 num_list = list(str(n)) for element in num_list: answer += int(element) return answer 3안) solution.py def solution(n): answer = 0 while n > 0: answer = answer + n % 10 n = int(n / 10) answer = answer + n return.. 더보기
[코딩테스트 입문] 짝수와 홀수 짝수와 홀수 1안) solution.py def solution(num): answer = '' if num % 2 == 0: answer = str("Even") else: answer = str("Odd") return answer 2안) solution.py def solution(num): answer = '' if num % 2 == 1: answer = str("Odd") else: answer = str("Even") return answer 출처 - 프로그래머스(코딩테스트 연습) : https://school.programmers.co.kr/learn/courses/30/lessons/12937 파이션 if else a = 200 b = 33 if b > a: print("b is grea.. 더보기
[코딩테스트 입문] 평균 구하기 평균 구하기 1안) solution.py def solution(arr): answer = 0 answer = sum(arr) / len(arr) return answer 2안) solution.py import statistics def solution(arr): answer = 0 answer = statistics.mean(arr) return answer 출처 - 프로그래머스(코딩테스트 연습) : https://school.programmers.co.kr/learn/courses/30/lessons/12944 파이썬 sum() 함수 a = (1, 2, 3, 4, 5) x = sum(a) print(x) 15 파이썬 len() 함수 mylist = ["apple", "orange", "cherry".. 더보기
[코딩테스트 입문] 개미 군단 개미 군단 1안) solution.py def solution(hp): answer = 0 a = hp // 5 b = (hp % 5) // 3 c = (hp % 5) % 3 answer = a + b + c return answer 2안) solution.py def solution(hp): answer = 0 answer = (hp // 5) + ((hp % 5) // 3) + ((hp % 5) % 3) return answer 3안) solution.py def solution(hp): answer = 0 a = divmod(hp, 5) b = divmod(a[1], 3) c = divmod(b[1], 1) answer = a[0] + b[0] + c[0] return answer 4안) solut.. 더보기

반응형