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

TGINSIGHT SIMILAR POSTS

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

Изворен канал @pythonotes · Post #146 · 16 сеп.

Функция sub в regex может принимать функцию в качестве аргумента repl. 📄 Из документации: If repl is a function, it is called for every non-overlapping occurrence of pattern. The function takes a single match object argument, and returns the replacement string. То есть для каждого совпадения будет вызвана функция для вычисления замены вместо замены на одну и ту же строку для всех совпадений. Иными словами, для замены разных совпадений на разные строки не потребуется запускать re.sub() много раз для каждой строки замены. Достаточно определить функцию, которая вернёт строку для каждого из совпадений. Описание слишком запутанное🤔, давайте лучше рассмотрим на простом примере: Создаем карту замены. То есть какие строки на какие требуется менять. remap = { 'раз': '1', 'два': '2', 'три': '3', 'четыре': '4', 'пять': '5', } Пишем функцию поиска строки для замены. Единственным аргументом будет объект re.Match. Используя данные этого объекта мы вычисляем замену on-the-fly! def get_str(match: re.Match): word = match.group(1) return remap.get(word.lower()) or word Пример текста. text = '''Раз Два Три Четыре Пять Вместе будем мы считать Пять Четыре Три Два Раз Мы считать научим вас ''' Теперь запускаем re.sub и вместо строки замены (repl) подаём имя функции. (Данный паттерн ищет отдельные слова в тексте) >>> print(re.sub(r'(\w+)', get_str, text)) 1 2 3 4 5 Вместе будем мы считать 5 4 3 2 1 Мы считать научим вас Думаю, достаточно наглядно 🤓 #libs#regex

Hashtags

Резултати

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

Пребарај: #opt

当前筛选 #opt清除筛选
🎺星空瞭望

@panguliaowang · Post #18347 · 26.05.2020 г., 00:33

#留学生 20200525 普要拿留学生"开刀"? OPT和H1B或受重大限制 5月24日最新消息!川普真的要对留学生"动手了",若新政策获批,数十万留学生将受重大影响... OPT,H1B 将受重大限制 美国华尔街日报以及Vox最新新闻,指出,川普可能会在数周内对留学生OPT及H1B做重大限制。这些限制很有可能是: #OPT: 暂停或缩短新的OPT签发,禁止留学生进入某些行业应聘; #H1B: 暂停或缩短新的H1B签证,H1B从三年签证变一年签证。 随后,福布斯,彭博社都立刻跟进了此条新闻。可以初步预测,近期留学生毕业后的身份及就业,或受重大影响。 1B拒绝率30%, 20万H1B恐丢身份首先,已经初现困境端倪的是H1B申请和就业:今年的H1B签证拒绝率高达30%!如果不幸地成为那百分之30%,届时很有可能面临工签没批准,学生签证身份也已经过期的两难境地。 这还没完,有幸运儿好不容易找着工作,也受疫情影响恐怕要失业了。找到工作也出问题就在4月22日,川普政府发布一项总统令,暂停大多数新移民入境至少60天,并下令进行30天审查,以建议对临时签证持有人实行新的限制 万维

MessageInABottle

@mib_messageinabottle · Post #6992 · 27.05.2024 г., 19:03

ICC CASE AGAINST URSULA Von Der LEYEN - FOR COMPLICITY IN WAR CRIMES AND CRIMES AGAINST HUMANITY IN GAZA Today the International Criminal Court (#ICC) has been officially called to investigate Ursula von der Leyen for #complicity in acts of #Genocide. Reasonable grounds exist to believe that the unconditional support of the president of the #European Commission to #Israel – #military, #economic, #diplomatic and #political – has enabled #WarCrimes and the ongoing genocide in #Gaza. – A communication is submitted today to the Office of the Prosecutor of the International Criminal Court (ICC), setting forth in detail, through facts and evidence, that there are reasonable grounds to believe that the current president of the European Commission, Mrs. Ursula von der Leyen, a national of Germany, is complicit in a number of violations of international humanitarian law, amounting to crimes within the jurisdiction of the ICC, committed by the Israeli armed forces (#IDF) against #Palestinian civilians in the #Occupied Palestinian Territory (#OPT), including the #Gaza Strip. This communication, endorsed by various human rights groups and prominent academics and experts in international criminal law, calls the Prosecutor to initiate investigations on the basis of the information provided against Mrs. Ursula von der Leyen. The communication documents in detail the fact that Mrs. Ursula von der Leyen personally is criminally responsible and liable for punishment for some of the war crimes, #CrimesAgainstHumanity and #genocide having been committed (and still being committed) by the Israeli armed forces in the #OPT, to the extent that she has aided, abetted and otherwise assisted in the commission or attempted commission of such crimes, including providing the means for its commission, in the meaning of Article 25(3)(c) of the #RomeStatute of the #ICC. MRS. VON DER LEYEN ENJOYS NO FUNCTIONAL IMMUNITY BEFORE THE ICC BY VIRTUE OF ARTICLE 27 OF THE ROME STATUTE.