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

Резултати

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

Пребарај: #ufed

当前筛选 #ufed清除筛选
Libreware

@libreware · Post #1144 · 26.05.2023 г., 13:59

Lock and wipe on emergency. You can use PanicKit, tile,shortcut or send a message with a secret code. On trigger, using Device Administration API, it locks a device and optionally runs wipe (factory reset). Or it can send a broadcast message instead of the wipe. Also you can: fire when a device was not unlocked for X time fire when a USB data connection is made while a device is locked fire when a fake messenger app is launched fire when a duress password is entered (companion app: Duress) The app works in Work Profile too, but with limitations. Use it to install risky apps and Wasted in it. Then you can wipe this profile data with one click without wiping the whole device. For base security take a look at: Sentry.Only encrypted device may guarantee that the data will not be recoverable. Be aware that the app does not work in safe mode. Wasted (Lock a device and delete its data in an emergency) https://f-droid.org/packages/me.lucky.wasted/ https://github.com/x13a/Wasted #security#cellebrite#UFED