๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐Ÿ | Python/ํŒŒ์ด์ฌ ์ดˆ๊ฐ„๋‹จ ํ”„๋กœ์ ํŠธ6

[Python] BLE ํ†ต์‹  ํ•˜๊ธฐ with bleak (MacOS) - 2) ๋ฐ์ดํ„ฐ ๋ฐ›๊ธฐ 2023.05.24 - [๐Ÿ | Python/ํŒŒ์ด์ฌ ์ดˆ๊ฐ„๋‹จ ํ”„๋กœ์ ํŠธ] - [Python] BLE ํ†ต์‹  ํ•˜๊ธฐ with bleak (MacOS) - 1) ํƒ์ƒ‰, ์—ฐ๊ฒฐ ์ง€๋‚œ ํฌ์ŠคํŠธ์—์„œ๋Š” bleak ๋ชจ๋“ˆ์„ ์ด์šฉํ•ด ์ฃผ๋ณ€ ๊ธฐ๊ธฐ๋ฅผ ํƒ์ƒ‰ํ•˜๊ณ  ์—ฐ๊ฒฐํ•˜๋Š” ๊ฒƒ์„ ํ•ด๋ณด์•˜๋‹ค. ์ด๋ฒˆ์—๋Š” ํ˜„์žฌ Kit์˜ ์„œ๋น„์Šค ์ •๋ณด๋ฅผ ์•Œ์•„๋ณด๊ณ  ๊ทธ๋ฅผ ํ™œ์šฉํ•˜์—ฌ kit๋กœ๋ถ€ํ„ฐ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ›์•„๋ณด์ž! 1. ์—ฐ๊ฒฐํ•œ ์žฅ์น˜์˜ ์„œ๋น„์Šค 1) ์—ฐ๊ฒฐ๋œ ์„œ๋น„์Šค ํ™•์ธ import asyncio from bleak import BleakClient, BleakScanner async def main (): devices = await BleakScanner.discover() for idx, device in enumerate(devices): print(f'{idx}\t\t',.. 2023. 5. 24.
[Python] BLE ํ†ต์‹  ํ•˜๊ธฐ with bleak (MacOS) - 1) ํƒ์ƒ‰, ์—ฐ๊ฒฐ ํŒŒ์ด์ฌ์˜ ๋ชจ๋“ˆ ์ค‘ bleak์„ ์ด์šฉํ•˜์—ฌ Mac์—์„œ BLE ํ†ต์‹ ์„ ํ•ด๋ณด์ž! 1. BLE๋ž€ ๋ฌด์—‡์ธ๊ฐ€ BLE๋Š” Bluetooth Low Energy์˜ ์•ฝ์ž๋กœ ๋ธ”๋ฃจํˆฌ์Šค์™€ ๊ฐ™์ง€๋งŒ ๋” ๋น ๋ฅด๊ณ  ๊ฐ€๋ณ๊ฒŒ ํ†ต์‹ ํ•˜๋Š” ๋ฐฉ๋ฒ•์ด๋‹ค. ๋•Œ๋ฌธ์— ์Šค๋งˆํŠธ ์›Œ์น˜, ํƒœ๊ทธ, ์ž‘์€ ์žฅ์น˜๋“ค์— ์ฃผ๋กœ ์ด์šฉํ•œ๋‹ค. ์ด๋ฅผ ์ด์šฉํ•ด์„œ ์‹ฌ์ „๋„, ๋ฉ”์‹œ์ง€ ํ†ต์‹  ๋“ฑ ๋‹ค์–‘ํ•œ ์„œ๋น„์Šค๋ฅผ ์ œ๊ณตํ•  ์ˆ˜ ์žˆ๋‹ค. 2. bleak ๋ชจ๋“ˆ ์ด์šฉํ•˜๊ธฐ bleak๋Š” ํŒŒ์ด์ฌ์—์„œ ๋ธ”๋ฃจํˆฌ์Šค LE๋ฅผ ์ง€์›ํ•˜๋Š” ๋ชจ๋“ˆ์ด๋‹ค. ์ด ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅด ํ†ตํ•ด์„œ MacOS, Windows, Linux ๋“ฑ์—์„œ๋„ ๊ฐ„ํŽธํ•˜๊ฒŒ ์žฅ์น˜์— ์—ฐ๊ฒฐํ•˜๊ณ  ๋ฐ์ดํ„ฐ๋ฅผ ํ†ต์‹ ํ•  ์ˆ˜ ์žˆ๋‹ค. ์•„๋ž˜์—์„œ๋Š” bleak์„ ์ด์šฉํ•œ ๊ฐ„๋‹จํ•œ ์˜ˆ์‹œ๋“ค์ด๋‹ค. --- ์‹ค์Šตํ™˜๊ฒฝ python 3.9.6 bleak 0.20.2 ์ˆ˜ํ–‰ ๋‹จ๊ณ„ ์š”์•ฝ 1. Bluetooth ์žฅ๋น„ O.. 2023. 5. 24.
Python_์—ฌ์ˆ˜๋ฐค๋ฐ”๋‹ค '์•„' ํšŸ์ˆ˜๋ฅผ ์„ธ์–ด๋ณด์ž 'ํ์•„ใ…ใ…'๊ฐ€ ๋‚˜์˜ฌ ๋•Œ๋งˆ๋‹ค ํ•œ ์ž”์„ ํ•˜๋Š” '์žฅ๋ฒ”์ค€ ๊ฒŒ์ž„'๋„ ์žˆ๋Š” ๋งŒํผ ์—ฌ์ˆ˜๋ฐค๋ฐ”๋‹ค ๋…ธ๋ž˜์˜ '์•„' ํšŸ์ˆ˜๋ฅผ ์„ธ์–ด๋ณด์•˜๋‹ค. ์—ฌ์ˆ˜ ๋ฐค๋ฐ”๋‹ค ์ด ์กฐ๋ช…์— ๋‹ด๊ธด ์•„๋ฆ„๋‹ค์šด ์–˜๊ธฐ๊ฐ€ ์žˆ์–ด ๋„ค๊ฒŒ ๋“ค๋ ค์ฃผ๊ณ ํŒŒ ์ „ํ™œ ๊ฑธ์–ด ๋ญํ•˜๊ณ  ์žˆ๋ƒ๊ณ  ๋‚˜๋Š” ์ง€๊ธˆ ์—ฌ์ˆ˜ ๋ฐค๋ฐ”๋‹ค ์—ฌ์ˆ˜ ๋ฐค๋ฐ”๋‹ค ์•„ ์•„ ์•„ ์•„ ์•„ ์–ด ์–ด ๋„ˆ์™€ ํ•จ๊ป˜ ๊ฑท๊ณ  ์‹ถ๋‹ค ์ด ๋ฐ”๋‹ค๋ฅผ ๋„ˆ์™€ ํ•จ๊ป˜ ๊ฑท๊ณ  ์‹ถ์–ด ์ด ๊ฑฐ๋ฆฌ๋ฅผ ๋„ˆ์™€ ํ•จ๊ป˜ ๊ฑท๊ณ  ์‹ถ๋‹ค ์ด ๋ฐ”๋‹ค๋ฅผ ๋„ˆ์™€ ํ•จ๊ป˜ ๊ฑท๊ณ  ์‹ถ์–ด ์—ฌ์ˆ˜ ๋ฐค๋ฐ”๋‹ค ์—ฌ์ˆ˜ ๋ฐค๋ฐ”๋‹ค ์ด ๋ฐ”๋žŒ์— ๊ฑธ๋ฆฐ ์•Œ ์ˆ˜ ์—†๋Š” ํ–ฅ๊ธฐ๊ฐ€ ์žˆ์–ด ๋„ค๊ฒŒ ์ „ํ•ด์ฃผ๊ณ ํŒŒ ์ „ํ™œ ๊ฑธ์–ด ๋ญํ•˜๊ณ  ์žˆ๋ƒ๊ณ  ๋‚˜๋Š” ์ง€๊ธˆ ์—ฌ์ˆ˜ ๋ฐค๋ฐ”๋‹ค ์—ฌ์ˆ˜ ๋ฐค๋ฐ”๋‹ค ์•„ ์•„ ์•„ ์•„ ์•„ ์–ด ์–ด ๋„ˆ์™€ ํ•จ๊ป˜ ๊ฑท๊ณ  ์‹ถ๋‹ค ์ด ๋ฐ”๋‹ค๋ฅผ ๋„ˆ์™€ ํ•จ๊ป˜ ๊ฑท๊ณ  ์‹ถ์–ด ์ด ๊ฑฐ๋ฆฌ๋ฅผ ๋„ˆ์™€ ํ•จ๊ป˜ ๊ฑท๊ณ  ์‹ถ๋‹ค ์ด ๋ฐ”๋‹ค๋ฅผ ๋„ˆ์™€ ํ•จ๊ป˜ ๋„ˆ์™€ ํ•จ๊ป˜ ์˜ค ๋ฐ”๋‹ค ์ด ์กฐ๋ช…์— ๋‹ด๊ธด ์•„๋ฆ„๋‹ค์šด ์–˜๊ธฐ๊ฐ€ .. 2022. 1. 17.
์›น ํฌ๋กค๋ง _ ๋ฆฌ๊ทธ์˜ค๋ธŒ๋ ˆ์ „๋“œ ์ „์  ๊ฒ€์ƒ‰๊ธฐ ๊ฐœ์š” ์œ ๋ช… ๊ฒŒ์ž„ '๋ฆฌ๊ทธ์˜ค๋ธŒ๋ ˆ์ „๋“œ'์˜ ์ „์  ๊ฒ€์ƒ‰ ์‚ฌ์ดํŠธ์ธ OP.GG์—์„œ ์›น ํฌ๋กค๋ง์„ ํ•ด๋ณด์•˜๋‹ค! ์‚ฌ์šฉ์ž๊ฐ€ ๋‹‰๋„ค์ž„์„ ๊ฒ€์ƒ‰ํ•˜๋ฉด ํ•ด๋‹น ์œ ์ €์˜ ์ตœ๊ทผ 20๊ฐœ์˜ ๊ฒŒ์ž„ ์ „์ ์ด ์ถœ๋ ฅ์ด ๋œ๋‹ค. โ–ผ์ฝ”๋“œ https://github.com/Bluishhot-Star/WEB/blob/master/LolStatCrawl.py ์‚ฌ์šฉํ•œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ bs4, requests ๊ณผ์ • ์‚ฌ์ดํŠธ์˜ url์„ ์‚ดํŽด๋ณด๋‹ˆ ์‚ฌ์šฉ์ž๊ฐ€ ๊ฒ€์ƒ‰์ฐฝ์— ์œ ์ €์˜ ๋‹‰๋„ค์ž„์„ ์ž…๋ ฅํ•˜๋ฉด API๊ฐ€ ์ž…๋ ฅํ•œ ๋‹‰๋„ค์ž„์„ ๊ทธ๋Œ€๋กœ ์ „๋‹ฌํ•˜๋Š” ๊ฒƒ์„ ๋ฐœ๊ฒฌํ–ˆ๋‹ค. ์œ„์˜ url์„ ์กฐ๊ธˆ ๋ถ„์„ํ•ด๋ณด๋ฉด api์ฃผ์†Œ์ธ summoner ์ „๋‹ฌํ•  ๋ฐ์ดํ„ฐ์ธ userName=(์‚ฌ์šฉ์ž๋‹‰๋„ค์ž„) ์ด๋•Œ userName์•ž์— ?๊ฐ€ ์ˆจ๊ฒจ์ ธ ์žˆ๋‹ค.(?๋ฅผ ์ž…๋ ฅํ•ด๋„ ์ •์ƒ ์ž‘๋™๋จ!) ์ด๋ฅผ ์ด์šฉํ•ด์„œ ์‚ฌ์šฉ์ž์˜ ์ž…๋ ฅ๊ฐ’์„ ๋ณ€์ˆ˜๋กœ ๋ฐ›์•„์„œ ํฌ๋กค๋ง ํ• .. 2021. 12. 27.
์ฃผ์‚ฌ์œ„ ๋ฒ ํŒ… ๊ฒŒ์ž„ ์Šคํ„ฐ๋””ํ•˜๋ฉด์„œ ๋ฐฑ์ค€๋ธŒ๋ก ์ฆˆ๋ฌธ์ œ์— ์žˆ๋˜ ๊ฒƒ์„ ์‘์šฉํ•ด์„œ ๋ฒ ํŒ… ๊ฒŒ์ž„์„ ๋งŒ๋“ค์–ด๋ณด์ž! ๋ผ๊ณ  ์ƒ๊ฐ์ด ๋“ค์–ด์„œ ์ฆ‰ํฅ์ ์œผ๋กœ ๋งŒ๋“ค์–ด๋ณด์•˜์Šต๋‹ˆ๋‹ค. from random import * import time dice_list=[] point = 1000 game = 1 cnt = 1 print('-์ฃผ์‚ฌ์œ„ ๊ฒŒ์ž„-') print(''' [๊ทœ์น™] 1~6 ์ฃผ์‚ฌ์œ„ 3๊ฐœ์˜ ๊ฒฐ๊ณผ์— ๋ฒ ํŒ…ํ•˜๋ผ! ์Šน๋ฆฌ ์‹œ ํ•ด๋‹น ํฌ์ธํŠธ ํš๋“ ์‹œ์ž‘ ํฌ์ธํŠธ 1000p [์Šน๋ฆฌ ํฌ์ธํŠธ] ๊ฐ™์€ ๋ˆˆ 3๊ฐœ : ๋ฒ ํŒ…ํฌ์ธํŠธ +(๊ฐ™์€ ๋ˆˆ)×1,0000p ๊ฐ™์€ ๋ˆˆ 2๊ฐœ : ๋ฒ ํŒ…ํฌ์ธํŠธ +(๊ฐ™์€ ๋ˆˆ)×200p ๋ชจ๋‘ ๋‹ค๋ฅธ ๋ˆˆ : ๋ฒ ํŒ…ํฌ์ธํŠธ + (๊ฐ€์žฅ ํฐ ๋ˆˆ)×100p [๋ฆฌ์Šคํฌ] ๊ฐ™์€ ๋ˆˆ 3๊ฐœ : ๋‚จ์€ ํฌ์ธํŠธ์˜ 75% ๊ฐ™์€ ๋ˆˆ 2๊ฐœ : ๋‚จ์€ ํฌ์ธํŠธ์˜ 50% ๋ชจ๋‘ ๋‹ค๋ฅธ ๋ˆˆ : ๋‚จ์€ ํฌ์ธํŠธ์˜ 5.. 2021. 11. 3.
์ˆซ์ž์•ผ๊ตฌ ์Šคํ„ฐ๋””์›์ด ์ˆซ์ž์•ผ๊ตฌ ๋งŒ๋“ค์–ด๋ณด๊ณ  ์‹ถ๋‹คํ•˜์—ฌ ํ•œ ๋ฒˆ ํ•ด๋ดค์Šต๋‹ˆ๋‹ค! from random import * import time def insufficient(numlist): # ๋ถ€์กฑํ•  ๊ฒฝ์šฐ insufficient_cnt = 4 - len(numlist) # ๋ถ€์กฑํ•œ ๊ฐœ์ˆ˜๋ฅผ ๊ณ„์‚ฐ print(f"์ค‘๋ณต๋œ ์ˆ˜ ํ˜น์€ ์ ์€ ์–‘์˜ ์ˆ˜๋ฅผ ์ž…๋ ฅํ•˜์˜€์Šต๋‹ˆ๋‹ค. ์ถ”๊ฐ€๋กœ {insufficient_cnt}๊ฐœ์˜ ๋‹ค๋ฅธ ์ˆ˜๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.") print("ํ˜„์žฌ ์ž…๋ ฅ๋œ ์ˆ˜", end=' : ') numlist.sort() for i in range(len(numlist)): print(numlist[i], end=' ') print('') while True: num = input(": ") # ์ž…๋ ฅ! if len(num) != insuffici.. 2021. 11. 3.
๋ฐ˜์‘ํ˜•