Тип строки в 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
It might look a little confusing at first, but pay attention.
On this chart we have DXY, GOLD and BTC.
DXY, which is a representative chart of the USD, has an inverse relationship with GOLD and BTC.
This is because when the dollar is strong, big money moves into high interest bonds that are safe.
When the dollar weakens, big money moves into safe havens and riskier assets.
What we can firstly see on the chart is that every time DXY drops, GOLD almost instantly moves higher.
Secondly, we can see that BTC also moves higher, but it lags behind GOLD.
But that’s not the most interesting thing…
The most interesting thing here is that every single time DXY has entered a down trend, BTC has began its move between 133 days and 140 days later.
This time, that gives us an end of May date as to when BTC will begin its next true move higher.
It’s just facts, right there for you to see.
#CryptoSignal#Binance#PumpAlert#FuturesTrade
30 day PNL screenshot14 New tarde profit ✈️✈️If you're want this
Type profit in 7 days ..
✅ Don’t miss the next big move — join our VIP Premium Channel now!
📩 Contact: @Future3366
🚀 Real-time signals | Pump alerts | Future trades
#CryptoSignals#VIPAccess#BinanceFutures#PumpAlert#CryptoProfits