안녕하세요! 파이썬 처음처럼입니다.
한국거래소에서 긁어 모은 KOSPI 기업 시가총액 전체 순위 월초 자료를 공유합니다. 시가총액 순위가 기록된 1995년부터 2019년까지 월초인 해당월의 1일부터 5일까지를 긁어 모았습니다.
(한국거래소 http://marketdata.krx.co.kr/)
KOSPI 기업 시가총액 전체 순위 월초 자료 다운로드
*
개장일이 아닌 날은 제외하였습니다.
*
방대한 자료 중 아래의 날짜의 데이터는 빠져있습니다.
(20191105, 20111203, 20060704, 19970503)
*
csv파일로 구성되어있습니다.
파이썬 처음처럼
파이썬에 관한 모든 것
2019년 12월 22일 일요일
2019년 12월 17일 화요일
How to implement Autohotkey's imeagesearch function in Python
Hello everyone. For Work automation, Python!
So today we will learn how to implement Autohotkey's imeagesearch functionality in Python.
First, download imagesearch.py from drov0's Github. And put imeagesearch.py in py file's path to be created.
(https://github.com/drov0/python-imagesearch)
Second, install following libraries. Run Python in the location of requirements.txt in the downloaded folder and proceed with pip3 install -r requirements.txt. The best thing to do is to install it through Anaconda and proceed with the installation of additional libraries.
Required libraries
- opencv-python
- numpy
- python3_xlib
- pyautogui
If do perfectly, preparation is completed!
Now put the image file you want to find in the path. Let's design a program that clicks on the Google logo.
As shown below, capture only a part of Google logo and put in path as google.png file.
Then write python file like below.
Explanation
line 1 from imagesearch import *: imports imagesearch.py
line 3 img = './google_logo.png': Put the path of the image file you want to find in the variable img.
line 4 pos = imagesearch (img): Find the image file and insert the mouse coordinates in the variable pos.
line 5 if pos [0]! = -1: : If pos value is normal, excute.
line 6 click_image (img, pos, 'left', 0.1): Randomly clicks pos position within img size, having a 0.1 second mouse movement time.
Through your browser, open the Google logo window that looks like the image we have, and run that py file. If you recognize the image and click on the Google logo, it's a success!
Thank you.
Korean Language Version link is
(https://pyinweb.blogspot.com/2019/04/imagesearch.html)
So today we will learn how to implement Autohotkey's imeagesearch functionality in Python.
First, download imagesearch.py from drov0's Github. And put imeagesearch.py in py file's path to be created.
(https://github.com/drov0/python-imagesearch)
Click the [Clone or download] button, You will get imagesearch.py |
Second, install following libraries. Run Python in the location of requirements.txt in the downloaded folder and proceed with pip3 install -r requirements.txt. The best thing to do is to install it through Anaconda and proceed with the installation of additional libraries.
Required libraries
- opencv-python
- numpy
- python3_xlib
- pyautogui
If do perfectly, preparation is completed!
Now put the image file you want to find in the path. Let's design a program that clicks on the Google logo.
Google logo |
As shown below, capture only a part of Google logo and put in path as google.png file.
![]() |
Capture the red box and make it a png file |
Then write python file like below.
from imagesearch import *
img = './google_logo.png'
pos = imagesearch(img)
if pos[0] != -1:
click_image(img, pos, 'left', 0.1)
Explanation
line 1 from imagesearch import *: imports imagesearch.py
line 3 img = './google_logo.png': Put the path of the image file you want to find in the variable img.
line 4 pos = imagesearch (img): Find the image file and insert the mouse coordinates in the variable pos.
line 5 if pos [0]! = -1: : If pos value is normal, excute.
line 6 click_image (img, pos, 'left', 0.1): Randomly clicks pos position within img size, having a 0.1 second mouse movement time.
Through your browser, open the Google logo window that looks like the image we have, and run that py file. If you recognize the image and click on the Google logo, it's a success!
Thank you.
Korean Language Version link is
(https://pyinweb.blogspot.com/2019/04/imagesearch.html)
라벨:
Autohotkey,
Automation,
imagesearch,
Python
2019년 4월 5일 금요일
파이썬 리스트의 이해
리스트list란?
프로그래밍 언어에서 가장 많이 사용하는 자료형입니다. 배열array이라고도 합니다.
파이썬에서는 리스트처럼 여러 데이터를 하나의 변수에 할당하는 기법을 시퀀스 자료형이라고 합니다.
인덱싱indexing
리스트에 있는 값에 접근하기 위해, 이 값의 상대적인 주소offset를 사용하는 것.
예)
city = ['Seoul', 'Busan', 'Daegu', 'Gwangju']
print(city[0])
print(city[3])
print(len(city))
결과:
Seoul
Gwangu
4
*len() 함수는 리스트 안에 있는 값의 갯수를 반환합니다.
슬라이싱slicing
리스트의 인덱스를 사용하여 전체 리스트에서 일부를 잘라내어 반환합니다.
기본 문법
변수명[시작 인덱스:마지막 인덱스]
리버스 인덱스reverse index
인덱스를 마지막 값부터 시작하는 기능입니다.
증가값step
기본 문법
변수명[시작 인덱스:마지막 인덱스:증가값]
리스트의 추가 및 삭제 함수
프로그래밍 언어에서 가장 많이 사용하는 자료형입니다. 배열array이라고도 합니다.
파이썬에서는 리스트처럼 여러 데이터를 하나의 변수에 할당하는 기법을 시퀀스 자료형이라고 합니다.
인덱싱indexing
리스트에 있는 값에 접근하기 위해, 이 값의 상대적인 주소offset를 사용하는 것.
예)
city = ['Seoul', 'Busan', 'Daegu', 'Gwangju']
print(city[0])
print(city[3])
print(len(city))
결과:
Seoul
Gwangu
4
*len() 함수는 리스트 안에 있는 값의 갯수를 반환합니다.
슬라이싱slicing
리스트의 인덱스를 사용하여 전체 리스트에서 일부를 잘라내어 반환합니다.
기본 문법
변수명[시작 인덱스:마지막 인덱스]
리스트와 인덱스 값 |
리버스 인덱스reverse index
인덱스를 마지막 값부터 시작하는 기능입니다.
리버스 인덱스 |
증가값step
기본 문법
변수명[시작 인덱스:마지막 인덱스:증가값]
리스트의 추가 및 삭제 함수
함수
|
기능
|
예시
|
append()
|
새로운 값을 기존 리스트의 맨 끝에 추가
|
city.append(‘Dokyo’)
|
extend()
|
새로운 리스트를 기존 리스트에 추가. 덧셈 연산과 같은 효과.
|
city.extend(‘Dokyo’, ‘Osaka’)
|
insert()
|
기존 리스트의 i번째 인덱스에 새로운 값을 추가. i번째 인덱스를 기준으로 뒤쪽의 인덱스는 하나씩 밀림
|
city.insert(1,‘Incheon’)
|
remove()
|
리스트 내의 특정 값을 삭제
|
city.remove(‘Busan’)
|
del
|
특정 인덱스값을 삭제
|
del city[1]
|
리스트의 메모리 저장
파이썬은 리스트를 저장할 때 값 자체가 아니라, 값이 위치한 메모리 주소reference를 저장합니다. 리스트 안에는 값 자체가 저장되는 게 아니라, 값이 메모리에서 위치한 메모리의 주소인 주소값을 저장합니다. C의 포인터 개념과 비슷합니다.
파이썬의 리스트에 대해 알아봤습니다. 감사합니다.
*위 내용은 최성철 교수의 책, '데이터 과학을 위한 파이썬 프로그래밍'(한빛아카데미)을 참고하여 작성하였습니다.
피드 구독하기:
덧글 (Atom)