Programming 32

파이썬 코루틴(coroutine)

파이썬 코루틴(coroutine) 파이썬 비동기 함수는 코루틴 함수로 만들 수 있다. 코루틴은 진입점과 탈출점이 여러 개가 있는 함수라고 할 수 있다. 파이썬 코루틴 공식 홈페이지에 있는 예제를 살펴보면 asyncio API에 대해 설명하고 있다. 다음 코드는 "hello"를 인쇄하고 1초를 기다린 다음 "world"를 인쇄한다. import asyncio async def main(): print('hello') await asyncio.sleep(1) print('world') asyncio.run(main()) 코루틴 함수를 만들기 위해는 함수 앞에 async 키워드를 붙여주면 된다. await는 어웨이터블 객체만 사용할 수 있으며, 코루틴 내에서 다른 코루틴을 호출하고 결과를 받을 때 사용된다. ..

Programming/Python 2022.10.02

PyAutoGUI를 통한 마우스 키보드 자동화

PyAutoGUI를 통한 마우스 키보드 자동화 PyAutoGUI 패키지를 통해 마우스, 키보드를 컨트롤하거나 스크린샷을 찍는 등의 자동화를 할 수 있다. 샘플코드 import pyautogui screenWidth, screenHeight = pyautogui.size() # Get the size of the primary monitor. screenWidth, screenHeight currentMouseX, currentMouseY = pyautogui.position() # Get the XY position of the mouse. currentMouseX, currentMouseY pyautogui.moveTo(100, 150) # Move the mouse to XY coordinates. ..

Programming/Python 2022.03.21

플러터(Flutter) 스터디 6주차

Udemy 플러터 강의 6주차 ㄴ Section 14. Bitcoin Ticker https://www.udemy.com/course/flutter-bootcamp-with-dart/ 이번 강의에서는 coin API를 호출하여 코인 가격 정보를 가져온 뒤, 각 나라의 화폐 단위로 출력해주는 앱을 구축하는 과정을 설명한다. 강의내용요약 Flutter DropdownButton iOS-style Cupertino Dart Loops 소스코드 coin_data.dart coin api 호출 map 형태로 각 코인에 대한 가격 정보 가져오는 변수 response json 데이터에 rate 값에 필요한 정보가 있음 import 'dart:convert'; // json 파싱 import 'package:http/..

Programming/Flutter 2021.11.13

플러터(Flutter) 스터디 5주차

Udemy 플러터 강의 5주차 ㄴ Section 13. Clima - Powering Your Flutter App with Live Web Data https://www.udemy.com/course/flutter-bootcamp-with-dart/ 이번 강의에서는 geolocator package를 이용해서 위도, 경도에 대한 위치 정보를 가져온 뒤, API를 이용하여 해당 위치(또는 도시)의 날씨 정보를 가져오는 앱을 구축하는 과정에 대해 설명한다. 강의내용요약 Flutter geolocator Package Stateful Widget Lifecycle http Package Passing Data Backwards Through the Navigation Stack Dart Futures, As..

Programming/Flutter 2021.11.07