Тип строки в 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
News: Finance Minister calls for nationwide #fuel conservation as gov’t considers further restrictions
#Ethiopia’s Finance Minister, #Ahmed_Shide, has urged consumers across the country to use fuel “with high conservation,” warning that additional measures aimed at curbing fuel consumption are currently under study.
The call came as the Ministry of Finance announced a new adjustment to domestic #petroleum prices, increasing fuel costs by up to 10 Birr per liter while warning that legal action has begun against entities accused of selling subsidized fuel above government-mandated prices.
In a briefing to journalists, Ahmed said the government is reminding all fuel users to exercise strict conservation. “We want to remind all fuel users that they must use fuel with high conservation,” he said, adding that additional measures currently under review will be announced to the public in the near future.
According to the ministry, the revised prices ……
Read more: https://addisstandard.com/?p=55769
News: #US. issues temporary waiver for #Iranian oil shipments already in transit
The Office of Foreign Assets Control (#OFAC) has issued a time-limited authorization allowing the delivery and sale of Iranian-origin crude oil and #petroleum products that were already loaded onto vessels before 20 March 2026.
In a notice released under “General License U,” the office, part of the U.S. Department of the Treasury, said transactions ordinarily prohibited under U.S. sanctions will be permitted if they are “incident and necessary” to the completion of shipments already in transit by the cutoff date.
The authorization allows activities including the sale, transport, and offloading of such cargoes until 19 April 2026, after which the standard sanctions regime resumes in full.
The measure does not lift broader sanctions on Iran but provides a narrow window to conclude pre-existing .....
https://www.facebook.com/AddisstandardEng/posts/pfbid046J7SQDcCLbGA4CpsTCDV5PcRKReRmpZrNkVZnsMQWdtrvsYjWwsQyaGK5gvfDRvl
NNPC Secures $1 Billion Investment
The Nigerian National Petroleum Corporation (NNPC) is set for a major funding round of $1 billion scheduled for December 17, 2024. For more details, visit their official page at NNPC LTD.
#NNPC#Investment#Funding#Oil#Petroleum#Nigeria#Energy#Finance#CorporateNews#December2024#BillionDollarRound
Funding Rounds Update: December 2024
Recent funding announcements highlight significant investments across various industries:
- ATC Managers, LLC: $14M on Dec 19, 2024 - Nationwide private lender.
- Boon: $15.5M on Dec 20, 2024 - AI solutions provider.
- Accelergen Energy: $20M on Dec 19, 2024 - Clean power asset management.
- Backflip AI: $30M on Dec 19, 2024 - AI content creation.
- Justt: $30M on Dec 19, 2024 - Chargeback automation.
- Decart: $32M on Dec 19, 2024 - Consumer AI platform.
- Instant Transport Solution: $35M on Dec 20, 2024 - Transportation technology.
- TBC Bank Uzbekistan: $37M on Dec 20, 2024 - Banking services.
- RiverWoods Exeter: $39.68M on Dec 18, 2024 - Retirement community.
- EPTME: $44M on Dec 16, 2024 - Lifestyle management.
- JET Charge: $44.93M on Dec 19, 2024 - EV charging solutions.
- Pasadena Private Lending: $50M on Dec 19, 2024 - Non-bank lending.
- Earli: $60M on Dec 19, 2024 - Cancer early detection.
- ALLO: $100M on Dec 19, 2024 - Real-world asset trading.
- DP World Group: $100M on Dec 19, 2024 - Logistics management.
- InoBat: $103.62M on Dec 20, 2024 - Sustainable battery production.
- ŌURA: $200M on Nov 19, 2024 - Health monitoring technology.
- Metsä Group: $208.40M on Dec 19, 2024 - Renewable products.
- Collectivus Holdings: $250M on Dec 19, 2024 - Investment management.
- Nigerian National Petroleum Corporation (NNPC): $1B on Dec 17, 2024 - Petroleum services.
#Funding#Investment#AI#Lending#Logistics#CleanEnergy#HealthTech#Batteries#ConsumerAI#EV#Retirement#Finance#Cancer#Sustainability#Transport#Renewables#RealEstate#Tech#NonBank#Petroleum#Automation