Строковый метод translate позволяет заменять или удалять несколько символов в строке за один раз. Это похоже на множественные вызовы метода replace.
```python import string
s = "Hello, world!" print(s.translate(str.maketrans("", "", string.punctuation))) # Hello world ```
Метод translate ожидает «таблицу перевода», которую мы создаем с помощью вспомогательного метода класса maketrans.
Третий аргумент (string.punctuation в примере) — это строка символов, которые мы хотим удалить.
Значение string.punctuation включает в себя следующие символы: !#$%&'()*+,-./:;?@[\]^_{|}~`
Суть шпаргалки заключается в том, что она демонстрирует, как эффективно удалить все стандартные знаки препинания из строки в Python, используя комбинацию методов str.maketrans для создания инструкции по удалению и str.translate для применения этой инструкции к строке.
Строковый метод translate позволяет заменять или удалять несколько символов в строке за один раз. Это похоже на множественные вызовы метода replace.
```python import string
s = "Hello, world!" print(s.translate(str.maketrans("", "", string.punctuation))) # Hello world ```
Метод translate ожидает «таблицу перевода», которую мы создаем с помощью вспомогательного метода класса maketrans.
Третий аргумент (string.punctuation в примере) — это строка символов, которые мы хотим удалить.
Значение string.punctuation включает в себя следующие символы: !#$%&'()*+,-./:;?@[\]^_{|}~`
Суть шпаргалки заключается в том, что она демонстрирует, как эффективно удалить все стандартные знаки препинания из строки в Python, используя комбинацию методов str.maketrans для создания инструкции по удалению и str.translate для применения этой инструкции к строке.
Telegram has exploded as a hub for cybercriminals looking to buy, sell and share stolen data and hacking tools, new research shows, as the messaging app emerges as an alternative to the dark web.An investigation by cyber intelligence group Cyberint, together with the Financial Times, found a ballooning network of hackers sharing data leaks on the popular messaging platform, sometimes in channels with tens of thousands of subscribers, lured by its ease of use and light-touch moderation.
Telegram Gives Up On Crypto Blockchain Project
Durov said on his Telegram channel today that the two and a half year blockchain and crypto project has been put to sleep. Ironically, after leaving Russia because the government wanted his encryption keys to his social media firm, Durov’s cryptocurrency idea lost steam because of a U.S. court. “The technology we created allowed for an open, free, decentralized exchange of value and ideas. TON had the potential to revolutionize how people store and transfer funds and information,” he wrote on his channel. “Unfortunately, a U.S. court stopped TON from happening.”