# Корисні бібліотеки https://github.com/vinta/awesome-python#command-line-tools ## Консольні штучки - `ipython` ![](https://i.imgur.com/aCGBRnP.png) - `howdoi` ![](https://i.imgur.com/RpTHepk.png) ![](https://i.imgur.com/nGvaJCT.png) - `requests` Вивести всі версії Майнкрафта ```python import requests for item in requests.get('https://launchermeta.mojang.com/mc/game/version_manifest.json').json()['versions']: print(item["id"]) ``` ## Наука - `matplotlib` (https://matplotlib.org/stable/gallery/) - `numpy` - `sympy` - (не пайтон) https://www.desmos.com/calculator ## Тексти - `nltk` --- natural language toolkit https://www.nltk.org/book/ch01.html - `textblob` ## Автоматизація - `pyautogui` - `keyboard` - `mouse` - `pyperclip` - `pytelegrambotapi` ## Графіка і діаграми - діаграми - `matplotlib` - `pyvis` ```python from pyvis.network import Network import pandas as pd got_net = Network(height='750px', width='100%', bgcolor='#222222', font_color='white') # set the physics layout of the network got_net.barnes_hut() got_data = pd.read_csv('https://www.macalester.edu/~abeverid/data/stormofswords.csv') sources = got_data['Source'] targets = got_data['Target'] weights = got_data['Weight'] edge_data = zip(sources, targets, weights) for e in edge_data: src = e[0] dst = e[1] w = e[2] got_net.add_node(src, src, title=src) got_net.add_node(dst, dst, title=dst) got_net.add_edge(src, dst, value=w) neighbor_map = got_net.get_adj_list() # add neighbor data to node hover data for node in got_net.nodes: node['title'] += ' Neighbors:<br>' + '<br>'.join(neighbor_map[node['id']]) node['value'] = len(neighbor_map[node['id']]) got_net.show('gameofthrones.html') ``` - `pillow` - `opencv` - розпізнавання: - `tesserocr` - `face_recognition` ```python import io import face_recognition import matplotlib.pyplot as plt import pyautogui from PIL import Image, ImageDraw focus = False default_region = (0, 0, 1920, 1080) plt.ion() fig = plt.figure() region = default_region while True: reg = (region[0], region[1], region[2]-region[0], region[3]- region[1]) img = pyautogui.screenshot(region=reg) out = io.BytesIO() img.save(out, 'JPEG') faceimg = face_recognition.load_image_file(out) loc = face_recognition.face_locations(faceimg) if loc: loc = loc[0] top, right, bottom, left = loc #pyautogui.moveTo((loc[0]+loc[2])/2, (loc[1]+loc[3])/2) print(loc) if focus: mg = 200 # margin region = (max(0, left-mg), max(0, top-mg), min(default_region[2]-1, right+mg), min(default_region[3]-1, bottom+mg)) draw = ImageDraw.Draw(img) draw.rectangle(((left, top), (right, bottom)), width=10, outline=(255, 255, 255)) else: print("no img") region = default_region plt.imshow(img) fig.canvas.draw() ``` - графіка для ігор - 2D: `pygame` - 3D: `PyOpenGL` https://hackmd.io/@pythondemo-v2/rkcgLClav