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

TGINSIGHT SIMILAR POSTS

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

Изворен канал @pythonotes · Post #254 · 11 јун.

Тип строки в 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

Hashtags

Резултати

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

Пребарај: #there

当前筛选 #there清除筛选
Social Justice Watch

@social_justice_watch · Post #17089 · 05.09.2022 г., 16:03

i get that people are more comfortable with defined rules and structure but i also think queer people lost when they started resorting to dictionary definitions for what labels mean the queer umbrella is meant to deviate from the norm of rigid boxes and definitions and to decide that lesbian means Only this, bi means Only this, etc, is directly contradicting what queer means. each and every label is going to have a unique meaning to the person using it and that is how it’s supposed to be. if you’re not comfortable with that…sorry? basically if someone tries to tell you you’re using a label wrong: [image description: a set of tumblr tags from @/elinaline, reading: “#there is a way to use a label wrong actually; #its when you force it on someone else”. end image description.] this is the only answer i’ll accept thank u everyone for your participation <3 https://genderkoolaid.tumblr.com/post/689713705918791680

Hashtags

Social Justice Watch

@social_justice_watch · Post #17075 · 05.09.2022 г., 12:49

i get that people are more comfortable with defined rules and structure but i also think queer people lost when they started resorting to dictionary definitions for what labels mean the queer umbrella is meant to deviate from the norm of rigid boxes and definitions and to decide that lesbian means Only this, bi means Only this, etc, is directly contradicting what queer means. each and every label is going to have a unique meaning to the person using it and that is how it’s supposed to be. if you’re not comfortable with that…sorry? basically if someone tries to tell you you’re using a label wrong: [image description: a set of tumblr tags from @/elinaline, reading: “#there is a way to use a label wrong actually; #its when you force it on someone else”. end image description.] this is the only answer i’ll accept thank u everyone for your participation <3 https://genderkoolaid.tumblr.com/post/689713705918791680

Hashtags