Тип строки в 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
green flag: IRAS bot will never get annoyed at you for asking the same questions every tax season 😅 Got a tax question? Use the IRAS bot to get help any time you need. 😉
https://www.iras.gov.sg/digital-services/others/iras-bot
#chatbot#irassg
Air Canada Ordered to Honor Chatbot's Impromptu Refund Policy
Hello everybody! In a landmark decision, Air Canada has been directed by Canada's Civil Resolution Tribunal to uphold a refund policy cited by its customer service chatbot. The ruling sets a potential precedent for similar cases involving automated customer service platforms.
The saga began when Jake Moffatt sought bereavement fares following his grandmother's passing in November 2022. Engaging with Air Canada's chatbot, he was informed of a retroactive refund option for reduced bereavement rates. Despite Air Canada's insistence that the chatbot's actions were independent, the tribunal ruled in Moffatt's favor, deeming the airline accountable for the chatbot's representations.
This decision not only obligates Air Canada to refund Moffatt's fare but also underscores the significance of accuracy and accountability in automated customer interactions. As chatbots become increasingly prevalent in customer service, the ruling highlights the need for companies to ensure consistency and reliability in their AI-driven communications.
#AirCanada#Chatbot
🧠 Google Gemini endi eski suhbatlaringizni eslab qoladi! 💾
Endi Gemini istalgan suhbatni eslab qoladi va kerak bo‘lsa, eski suhbatlaringizga o‘zi murojaat qiladi!😱
🔹RAG tizimi ishlaydi – oldingi chatlaringizdan ma’lumotni topish va ulardan foydalanish imkoniyati!
🔹Mavzuga mos bo‘lsa, AI o‘zi eslab qoladi va sizga kerakli faktlarni taqdim etadi.
🔹Siz istalgan suhbatga murojaat qilishingiz mumkin, hatto u uzoq vaqt oldin bo‘lsa ham!
📌Bitta muhim narsa:
🛑Cheksiz xotirani faollashtirish uchunGemini Advanced obunasi kerak.
🛑Hozircha faqat Flash modeli bilan ishlaydi.
🔮OpenAI ham shunday funksiyani ishlab chiqayotganini aytgandi… Ko‘ramiz, kim birinchi bo‘ladi!🚀
#Gemini#AI#Google#Chatbot
Shhh! Close the curtain quickly!
We don't want the neighbors to see anything! 🤫👀💥
Chat and see more selfies:
📲(iOS)
📲(Android)
#stepsis#aigirlfriend#chatbot
All of your image creations, all in one place.
Introducing the new library for your ChatGPT image creations—rolling out now to all Free, Plus, and Pro users.
➖➖➖➖🔻
💎@Chatgpt_OfficialNews – Stay Updated! ⚡️
🧠 BOT: @Chatgpt_OfficialBOT
#️⃣#OpenAI#AI#GPT#ChatGPT#Chatbot
➖➖➖➖🔺