TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #65 · 8 апр.

Небольшой трик с регулярными выражениями который редко вижу в чужом коде. Допустим, вам нужно распарсить простой текст и вытащить оттуда пары имя+телефон. Вернуть всё это надо в виде списка словарей. Возьмем очень простой пример текста. >>> text = ''' >>> Alex:8999123456 >>> Mike:+799987654 >>> Oleg:+344456789 >>> ''' Соответственно, для выделения нужных элементов будем использовать группы. Получится такой паттерн: (\w+):([\d+]+) Как мы будем формировать словарь из найденных групп? >>> import re >>> results = [] >>> for match in re.finditer(r"(\w+):([\d+]+)", text): >>> results.append({ >>> "name": match.group(1), >>> "phone": match.group(2) >>> }) >>> print(results) [{'name': 'Alex', 'phone': '8999123456'}, ...] Можно немного сократить запись используя zip >>> results = [] >>> for match in re.finditer(r"(\w+):([\d+]+)", text): >>> results.append(dict(zip(['name', 'phone'], match.groups()))) Но есть способ лучше! Это именованные группы в regex. Можно в паттерне указать имя группы и результат сразу забрать в виде словаря. >>> for match in re.finditer(r"(?P<name>\w+):(?P<phone>[\d+]+)", text): >>> results.append(match.groupdict()) То есть всё что я сделал, это добавил в начале группы (внутри сбокочек) такую запись: (?P<group-name>...) Теперь найденная группа имеет имя и можно обратиться к ней как к элементу списка >>> name = match['name'] Либо забрать сразу весь словарь методом groupdict() >>> match.groupdict() #tricks#regex

Резултати

Пронајдени 3 слични објави

Пребарај: #cua

当前筛选 #cua清除筛选
GitHub Trends

@githubtrending · Post #15063 · 15.08.2025 г., 13:00

#python#agents#ai#ai_ux#autogen#browser_use#computer_use_agent#cua#ui Magentic-UI is a tool that helps you automate complex web tasks by working together with you. It lets you plan step-by-step actions, watch the progress, and approve sensitive steps to keep control and safety. You can interact with it through a browser, upload files, and even run multiple tasks at once. It learns from past tasks to improve future automation. This means you save time on repetitive or complicated web activities while staying in control, making your work easier and more efficient. It supports Python 3.10+ and works best with Docker or WSL2 on Windows. https://github.com/microsoft/magentic-ui

GitHub Trends

@githubtrending · Post #14711 · 15.05.2025 г., 14:00

#python#agent#ai_agent#apple#computer_use#cua#lume#macos#manus#operator#swift#virtualization#virtualization_framework The information provided doesn't directly relate to Discord bots or their benefits. However, if we consider the broader context of automation and AI tools like those mentioned in the text, these technologies can enhance user experiences by automating tasks and providing interactive features. For example, AI agents can control virtual environments, which might be useful in various applications, including gaming or educational settings. This kind of automation can save time and increase efficiency, similar to how Discord bots automate tasks and engage communities[1][2]. https://github.com/trycua/cua

GitHub Trends

@githubtrending · Post #15071 · 18.08.2025 г., 12:30

#typescript#agent#agentic_ai#agents#ai#ai_agents#ai_tools#anthropic#automation#bytebot#computer_use#computer_use_agent#cua#desktop#desktop_automation#docker#gemini#llm#mcp#openai Bytebot is an open-source AI desktop agent that acts like a virtual employee with its own computer, able to use real applications, browse websites, handle passwords, and process documents automatically. You just describe tasks in plain English, and Bytebot completes them by clicking, typing, downloading files, organizing data, and running complex workflows across multiple programs. It runs locally on your own infrastructure, ensuring privacy and full control, and supports many AI models. This helps you save time by automating repetitive or complex tasks without scripting, improving efficiency and accuracy in business, research, or development work. https://github.com/bytebot-ai/bytebot