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

TGINSIGHT SIMILAR POSTS

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

Изворен канал @pythonotes · Post #22 · 19 јан.

Заметка начинающим, которые часто сталкиваются с подобной непоняткой. Ситуация следующая, есть список файлов: names = [ 'image.bmp', 'second.txt.bkp', 'data.db', '.config.cfg', 'file.ext.bkp' ] И мы хотим убрать у них окончание ".bkp". Не знаю зачем, пример довольно надуманный) Но суть он показывает, а это главное. Те, кто еще не очень знаком с библиотекой os.path или pathlib, вероятно решат обработать имена как строки. И тут вполне подойдет метод строки strip(). Что делает этот метод? Он отрезает указанные символы по обеим сторонам строки. Если ничего не указать, то убирает невидимые символы (пробелы, табуляции и переносы строк). В нашем случае будет выглядеть вот так: >>> name.strip('.bkp') То есть просим удалить строку '.bkp' по краям имени файла, если таковая есть. Можно применить аналогичный метод rstrip(), чтобы отрезать только справа, но для этого примера используем обычный. >>> for name in names: >>> print(name.strip('.bkp')) image.bm second.txt data.d config.cfg file.ext Хм, что-то не то с нашими именами! Что случилось??? Видим нежелательное переименование в именах, где и близко не было указанной строки '.bkp' А дело всё в том, что данный метод ищет не указанную строку, а указанные символы, и не важно в каком порядке. Для метода strip() строка '.bkp' это не паттерн для поискаа список символов. Потому он отрезал симовол 'p' от '.bmp' и удалил точку из файла '.config.cfg'. Как тогда правильно заменить именно паттерн? Для начинающего можно посоветовать метод строки replace(), который как раз использует для замены указанную строку целиком. В нашем примере заменим её на пустую строку. >>> for name in names: >>> print(name.replace('.bkp', '')) image.bmp second.txt data.db .config.cfg file.ext Уже лучше, но помните, это лишь пример про strip(). Для работы с именами файлов есть способы и более "правильные", дающие однозначно верный результат. Я взял файлы только в качестве примера. Даже replase() тут может сделать не то что ожидаем. Просто впредь будьте внимательны с этим strip(). #basic

Hashtags

Резултати

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

Пребарај: #breakthesiege

当前筛选 #breakthesiege清除筛选
Freedom Flotilla Coalition

@FFC_official_channel · Post #12 · 18.04.2024 г., 07:08

We're challenging Israel's illegal blockade of Gaza and delivering tonnes of critical aid to Palestinians in an emergency mission. Our destination is the conscience of humanity. Once we leave port, we will be posting regular updates on this channel and broadcasting live from on board the ships. We need you to get on board - on land. We need millions of people around the world, who have come out on the streets in support of Palestine, to help keep the participants safe and ensure the success of the mission. Together we can #BreakTheSiege Please share this channel and help us get the eyes of the world on this mission. When governments fail, we sail!

Freedom Flotilla Coalition

@FFC_official_channel · Post #373 · 03.06.2025 г., 03:11

UN EXPERTS DEMAND SAFE PASSAGE FOR ‘MADLEEN’ JOIN THEM Today, UN experts called for safe passage for the Madleen — our civilian ship carrying vital aid and international volunteers to Gaza. Now we need your voice. Let’s turn international law into action. 📣 Take one minute: go to bit.ly/IsraelOnNotice and send a letter to the Israeli government, UN officials, and diplomatic missions demanding that Israel abide by international law and refrain from attacking, sabotaging or otherwise interfering with the Madleen and her mission. Together, we can open a people’s sea corridor to Gaza. #SafePassage#BreakTheSiege#FreedomFlotilla

El Pueblo Informa

@EPInforma · Post #35508 · 13.06.2025 г., 14:40

Mientras el mundo se moviliza por Palestina y tratar de desbloquear Gaza, EE.UU. aprovecha de atacar a Irán con impunidad. Así negocia EE.UU. Qué alivio saber que Donald Trump sigue comprometido con "la diplomacia"... a su manera. No hay mejor Acuerdo de Paz que advertirle a un país entero que será reducido a cenizas. #iran #gaza #gazaunderattack #breakthesiege #usdiplomacy #diplomacy

Drones are now regularly flying over the flotilla. As Yasemin Acar, Steering Committee member of the Global Sumud Flotilla, explains: this surveillance is meant to intimidate and exhaust us. But it only underscores why our mission is urgent. For Palestinians, drones are not just cameras. They are weapons of war, used daily to surveil, intimidate, and kill. The same technology that terrorizes Gaza is now policing the Mediterranean, turning the sea into a graveyard. We will not turn back. We continue to Gaza because this is about justice, freedom, and life. #BreakTheSiege #FreePalestine #SailToGaza #GlobalMovementToGaza #GlobalSumudFlotilla

Freedom Flotilla Coalition

@FFC_official_channel · Post #649 · 21.07.2025 г., 08:24

'Handala’ left Italy a few hours ago and is almost in international waters. This action is for the children of Gaza. The boat is carrying as much baby formula, food, and medicine as possible, but its aim is to end the need for aid by breaking Israel’s illegal siege. Keep your eyes on our team, and demand their governments uphold international law by ensuring safe passage. #ForTheChildrenOfGaza #AllEyesOnDeck #BreaktheSiege #FreePalestine

As we enter the high-risk zone, follow our mission by tracking the flotilla live on our website. #BreakTheSiege#FreePalestine#SailToGaza #AllEyesOnGaza #GlobalMovementToGaza#GlobalSumudFlotilla

Freedom Flotilla Coalition

@FFC_official_channel · Post #586 · 13.07.2025 г., 02:16

The Freedom Flotilla Coalition is setting sail again. Join us in Siracusa, Italy — or online — on July 13 at 10:30 CEST (GMT+2) as we launch ‘Handala’ on its journey toward Gaza. Just weeks after Israeli forces illegally seized our boat ‘Madleen’ and abducted 12 unarmed civilians in international waters, we continue — with global solidarity — to challenge Israel’s illegal and deadly siege. This mission is for the children of Gaza. #FreedomFlotilla#WeWillSail#AllEyesOnDeck#BreakTheSiege#Handala

Freedom Flotilla Coalition

@FFC_official_channel · Post #665 · 22.07.2025 г., 12:43

LIVESTREAM FROM THE SEAS WITH THE FREEDOM FLOTILLA AND RASHIDA TLAIB. July 23 on Instagram and Telegram 10:00 AM (New York | EDT GMT-4) 5:00 PM (Palestine | EEST GMT+3) Join us for a powerful conversation between Congresswoman Rashida Tlaib and the U.S. citizens aboard ‘Handala’ as they sail to break Israel’s illegal siege on Gaza. Tune in to hear them discuss the moral responsibility of ordinary people when governments fail, the urgent need to change U.S. policy that enables Israel and their genocide of Palestinians, why they are sailing, what they are demanding, and how we can all stand with Gaza. #alleyesondeck#handala#forthechildrenofgaza#breakthesiege#endtheblockade

Freedom Flotilla Coalition

@FFC_official_channel · Post #531 · 11.06.2025 г., 12:13

Palestinians in Gaza are being starved, denied aid, genocided- and this is all on live stream and on our watch. A statement from Yasemin Acar, FFC volunteer on ‘Madleen’ who was kidnapped by IOF, forcibly taken to Israel and currently being held in detention is delivered by her brother J. Acar. This is the real story. #FreeGaza#BreakTheSiege #Madleen#EndTheGenocide

Freedom Flotilla Coalition

@FFC_official_channel · Post #708 · 26.07.2025 г., 12:44

Join us live on instagram as Francesca Albanese @francesca.albanese.unsr.opt talks with Emma Fourreau @emma.fourreau(French member of the European Parliament) and Gabrielle Cathala @gabrielle_cathala (member of the French Parliament) from the Handala as they discuss global government complicity in Israel’s war crimes. As the ‘Handala’ is nearly 100 nautical miles from the coast of Gaza, world governments should be doing all they can to ensure its safe passage. Today, July 26th at 16:30 EEST (Palestinian time) #BreakTheSiege#Handala#AllEyesOnDeck#Live#ForTheChildrenOfGaza

ПретходнаСтраница 1 од 4Следна