프로그래밍 공부 22

[Python] 리스트(배열), 튜플 괄호 없이 출력

방법은 여러가지가 있다. 예시로 num1=[1, 2, 3] --> 리스트(배열) num2=(4, 5, 6) -->튜플 을 사용해 보자. 1. 반복문 사용 가장 기본적이 방법입니다. man=(1, 2, 3) girl=[4, 5, 6] alpha=('a', 'b', 'c') for i in man:print(i, end=' ') print() for i in girl: print(i, end=' ') print() for i in alpha: print(i, end=' ') """ 결과 1 2 3 4 5 6 a b c """ 2. 문자열로 바꿔서 출력 (str 대신에 repr함수를 써도 똑같이 출력된다. 하지만 각 함수의 반환값이 다르다.) man=(1, 2, 3) girl=[4, 5, 6] alph=('a..

[운영체제] Pthread 자주 쓰는 자료형, 함수 모음

리눅스 운영체제에서 가능 (윈도우X), #include 넣기! 1. 자료형 pid_t: process id pthread_t : thread id pthread_attr_t : set of thread attributes (쓰레드 속성) 2. 함수 int pthread_attr_init(pthread_attr_t *attr): thread attribute 객체인 attr를 디폴트 값으로 초기화 시킨다. attr 의 각 값은 pthread_attr_setattrname를 이용해서 재설정할수 있으며, pthread_attr_getattrname함수를 이용해서 가져올수 있다. int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void*(st..

[백준] 1874: 스택 수열 문제풀이 (Python)

import sys #n=int(sys.stdin.readline()) #list=[4,3,6,8,7,5,2,1] dack=list() result=list() dack.append(1) dack.append(2) dack.append(3) dack.append(4) result.append(dack.pop()) result.append(dack.pop()) dack.append(5) dack.append(6) result.append(dack.pop()) dack.append(7) dack.append(8) result.append(dack.pop()) result.append(dack.pop()) result.append(dack.pop()) result.append(dack.pop()) result..

정규표현식(Regular Expression)

정규표현식(Regular Expression) 정규표현식: 문자열을 처리하는 방법 중의 하나로 특정한 조건의 문자를 '검색'하거나 '치환'하는 과정을 매우 간편하게 처리 할 수 있도록 하는 수단 /string(찾고자 하는 문자열)/옵션 으로 구성됨. -->/pattern/flag 설명 영상 --> https://www.youtube.com/watch?v=t3M6toIflyQ 연습 사이트!!!(매우 bb)--> https://regexr.com/5mhou 문제 사이트 --> https://regexone.com/ 정규 표현식 시각화 사이트 --> https://regexper.com/ flag 종류 1. global 2. case insensitive 3. multline 4. single line 5. ..

이미지 크롤링(python, google_images_download)

이전글(html크롤링--> https://sh1256.tistory.com/52?category=991734 ) 1. google_images_download 다운 --> https://pypi.org/project/google_images_download/ google_images_download Python Script to download hundreds of images from 'Google Images'. It is a ready-to-run code! pypi.org 터미널에 붙여넣기 (ctrl+shift+v) 그러면 설치된다. 홈페이지에 있는 documentation에서 예제를 실행해보자. Code sample - Importing the library 소스코드를 실행해보자. (google..

파이썬 텍스트 파일 쓰기

이전 글 --> https://sh1256.tistory.com/52 웹크롤링 하는 법(파이썬(python), beautifulsoup4) 1. goormIDE 접속 --> 회원가입 --> 컨테이너 생성(python 언어 선택) -->터미널에 pip install bs4 2. 빨간 네모 부분만 끌어오기 name --> link 형식 사용된 beautifulsoup4문법들: -->https://www.crummy.c.. sh1256.tistory.com python write text file 검색 -->https://wikidocs.net/26 아래코드 복붙 ++ 경로 설정 시 슬래시 방향 주의!!++경로 설정 없을 시 현재 폴더 아래에 생성 (현재 가상머신 이용중이여서 경로설정X) 성공

웹크롤링 하는 법(파이썬(python), beautifulsoup4)

1. goormIDE 접속 --> 회원가입 --> 컨테이너 생성(python 언어 선택) -->터미널에 pip install bs4 2. 빨간 네모 부분만 끌어오기 name --> link 형식으로 만들자. 사용된 beautifulsoup4문법들: -->https://www.crummy.com/software/BeautifulSoup/bs4/doc/ 파일에 저장해보자 (참고)--> https://sh1256.tistory.com/53?category=991734 파이썬 텍스트 파일 쓰기 이전 글 --> https://sh1256.tistory.com/52 회원가입 --> 컨테이너 생성(python 언어 선택) -->터미널에 pip install bs4 2. 빨간 네모 부분만 끌어오기 name --> li..

백준 연습문제 1002번 풀이

네 우선 문제를 정리해 봅시다. 조규현=A, 백승환=B, 류재명=C A의 좌표: x1, y1, B의 좌표: x2, y2 AC거리: r1, BC거리: r2 그럼 간단히 생각을 해 보면 A, B각각의 점에서 r1, r2의 길이만큼 원을 그렸을 때 겹치는 부분이 C가 있을 수 있는 수가 되겠네요 초 경우의 수는 6가지가 됩니다. 아래 슬라이드쇼를 봐 주세요!(옆으로 넘어갑니다.) 자 그럼 위의 경우에 맞게 코드를 짜 봅시다. #define _CRT_SECURE_NO_WARNINGS #include #include double distance(double x1, double y1, double x2, double y2) { double x = fabs(x1 - x2); double y = fabs(y1 - y2..