Тип строки в Python имеет очень много удобных методов. Сегодня пост про два таких метода которые чаще всего используются "однобоко". Это методы startswith() и endswith()
Самый обычный сценарий использования — проверка, начинается ли строка с указанной подстроки?
>>> "some_string".startswith("some")
True
И аналогичная ситуация с зеркальным вариантом этой функции, проверка совпадения с конца
>>> "some_string".endswith("some")
False
Так они используются в большинстве случаев что я видел. Но у этих функций есть еще два варианта использования.
🔸Сравнение нескольких подстрок
Для проверки нескольких подстрок в одной строке обычно вызывают эти функции несколько раз. Но на самом деле достаточно передать кортеж со всеми строками один раз. Если будет хоть одно совпадение то функция вернёт True.
>>>"my_image.png".endswith(("jpg", "png", "exr"))
True
🔸Диапазон поиска
Вторым аргументом можно передать индекс символа с которого следует начать сравнение, а третий аргумент это индекс последнего символа.
>>> ".filename.ext".startswith("file", 1)
True
>>> "file_###.ext".endswith('#', 0, -4)
True
Индексы можно указать отрицательными, что означает отсчёт с конца.
#trics#basic
⚠️ Blogerlar uchun YANGILIK: Captions kompaniyasi yangi Mirage texnologiyasini taqdim etdi. Neyron tarmoq noldan odamlarni yaratadi va ovozni video formatiga maksimal aniq oʻgiradi.
😱 Bu haqiqiy inqilob! Boshqa modellar faqat lablarni harakatlantirsa, Mirage hammasini qiladi:
✅ Tana modelini yaratadi
✅ Haqiqiydan ajratib bo'lmaydigan harakatlar
✅ Fon
✅ Tabiiy mimika
➡️https://www.captions.ai/mirage
➡️#ai#captions | Birinchi raqamli IT-Blog
· · • • • •❄️• · · INSTAGRAM · · •❄️• • • • · ·
Escribir captions en Instagram es un arte y es una excelente manera de impulsar el compromiso por parte de tu comunidad.
Tus descripciones son representaciones de tu marca. Y podrían ser la última pieza que necesitas mejorar para pasar de un feed bueno a uno profesional. De hecho, escribir captions en Instagram podría ser la clave para que tu publicación gane visibilidad. Así que lee estos Tips para escribir captions en Instagram y luego me cuentas que te parecen 😉.
#tips_instagram
#captions
· · • • • • • · · · · • • • ☃️• • • · · · · • • • • • · ·
· · • • • •🌼• · · INSTAGRAM · · •🌼• • • • · ·
Uno de los beneficios de los posts en Instagram es que puedes cargar fotografías, diseños, videos e incluso galerías de hasta 10 imágenes juntas. En este caso la clave es que lo que sea que uses como portada sea lo suficientemente atractivo para que los usuarios se detengan a leer tu caption.
#tips_instagram
#captions#consejos
· · • • • • • · · · · • • • 🍃• • • · · · · • • • • • · ·
#python#asr#captions#cli#python#subtitle#subtitles#transcript#transcripts#translating_transcripts#youtube#youtube_api#youtube_asr#youtube_captions#youtube_subtitles#youtube_transcript#youtube_transcripts#youtube_video
The YouTube Transcript API is a tool that helps you get the text from YouTube videos. It's fast and easy to use, saving you time compared to watching the whole video. You can use it to make subtitles, translate text, and even analyze what's being said in videos. This is helpful for content creators who want to make their videos more accessible and for researchers who need to study video content quickly. It also supports multiple languages, making it useful for a wide range of users.
https://github.com/jdepoix/youtube-transcript-api