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

Резултати

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

Пребарај: #azerbaijan

当前筛选 #azerbaijan清除筛选
肃反委员会

@KatyushaUnion · Post #7859 · 08.10.2023 г., 17:45

109 sq km of Azerbaijani territory is still under illegal occupation of Armenia. These are 7 villages (shown in the video) in the north and one village adjacent to Nakhchivan in the south. Armenia must return them to #Azerbaijan. https://twitter.com/NasimiAghayev/status/1710735177213763796

Hashtags

Voyage.Travel.Tourism

@VOYAGE · Post #1183 · 02.12.2024 г., 13:14

AZERBAIJAN 🇦🇿 Baku — the "Eastern Paris" on the shores of the Caspian Sea, the capital of Azerbaijan, an ancient city and a modern metropolis. Here, ancient alleys twist into labyrinths where the heroes of "Diamond Hand" once wandered. Elegant modern buildings with intricate balconies delight the eye, while mighty stone towers guard age-old secrets — and glass towers of skyscrapers gleam. Baku is as colorful as a masterpiece from the Carpet Museum and as cozy as a tea courtyard hidden in the depths of the Old City. #Azerbaijan @voyage

Hashtags

Voyage.Travel.Tourism

@VOYAGE · Post #1021 · 11.07.2024 г., 12:14

Azerbaijan 🇦🇿 Baku — the "Eastern Paris" on the shores of the Caspian Sea, the capital of Azerbaijan, an ancient city and a modern metropolis. Here, ancient alleys twist into labyrinths where the heroes of "Diamond Hand" once wandered. Elegant modern buildings with intricate balconies delight the eye, while mighty stone towers guard age-old secrets — and glass towers of skyscrapers gleam. Baku is as colorful as a masterpiece from the Carpet Museum and as cozy as a tea courtyard hidden in the depths of the Old City. #Azerbaijan @voyage

Hashtags

skhanzadeh.ir

@skhanzadeh_ir · Post #532 · 29.01.2023 г., 10:14

Azerbaijan's embassy gave illegal migration to the wife of an Iranian man. the man after months could not be patient. attacked the embassy with AK-47. the reaction of Azerbaijan's regime: 1. called this event a terrorist attack!!!! 2. wanna leave the embassy 3. will not say any response why they let the woman leaves Iran without permission when she was married and had 2 children. #Azerbaijan's regime is weird. @skhanzadeh_ir فناوری برای بشریت

Hashtags

ጠቅላይ ሚኒስትር ዐቢይ አሕመድ (ዶ/ር) በባኩ የክብር አደባባይ እና የድል ሀውልት የአበባ ጉንጉን አኖሩ ******* ጠቅላይ ሚኒስትር ዐቢይ አሕመድ (ዶ/ር) እና ቀዳማዊት እምቤት ዝንሽ ታያቸው በአዘርባጃን ባኩ በሚገኘው የክብር አደባባይ እና የድል ሀውልት የአበባ ጉንጉን የማስቀመጥ ሥነ ሥርዓት አከናውነዋል። ጠቅላይ ሚኒስትሩ በዚሁ ወቅት ባስተላለፉት መልዕክት፤ ሀውልቶቹ የሕዝቡን የማይበገር አንድነት የሚወክሉ መሆናቸውን ጠቁመዋል። ጠቅላይ ሚኒስትሩ ለአዘርባጃን አንድነት መስዋዕትነት ለከፈሉ ሁሉ ያላቸውን ጥልቅ ክብር ገልጸዋል። #EBC#Ethiopia#azerbaijan

Islamic World News

@iswnews_en · Post #16962 · 05.03.2026 г., 11:17

🇮🇷/🇦🇿🇮🇱✈️💥 Iran’s warning strike against Azerbaijan! ‼️ The armed forces of Iran reportedly targeted positions at the Nakhchivan International Airport in the Azerbaijan with a suicide drone. It appears that unusual activities linked to the Zionist regime have been observed in Azerbaijan, which may have prompted Iran to carry out this strike. 👉 However, some believe this attack could be a “false flag” operation intended to draw Baku into a confrontation with Iran. ✍️ Azerbaijan has for years been viewed as a base for the Zionist regime to conduct operations against Iran’s national security. This matter is not hidden, and security and military cooperation between Baku and Tel Aviv is taking place openly. #Iran#Azerbaijan

Islamic World News

@iswnews_en · Post #16881 · 04.03.2026 г., 10:19

🇮🇷/🇮🇱🇦🇿‼️It is said that the Iranian armed forces have attacked the assets of the Israeli regime inside the Republic of Azerbaijan. ✍️ For years, the Baku regime has turned its soil into a safe base for Israel, and the Israeli regime operates from there against the interests and national security of Iran. This time, no more! Iran is coming for you! #Iran#Azerbaijan

POPULAR FRONT

@popularxfront · Post #5282 · 06.03.2026 г., 11:08

🇮🇷#Iran - 🇦🇿#Azerbaijan: Emerging reports state that Azerbaijani troops have deployed artillery to the Iranian border to prepare for possible retaliatory attacks against the IRGC. (via @war_noir)

POPULAR FRONT

@popularxfront · Post #5274 · 05.03.2026 г., 10:08

🇮🇷#Iran – 🇦🇿#Azerbaijan: At least two Iranian drones struck Azerbaijani territory earlier today. According to Azerbaijani authorities, one Iranian drone, presumably launched by the IRGC, struck the terminal building of an airport in Nakhchivan, which can be seen in the footage. A second drone reportedly crashed near a school in the village of Shakarabad. Iran has not yet confirmed the attacks. Two people were injured as a result of the strikes. (via Reuters; 📹 via @war_noir)

Opportunities with Zula

@opportunities_zula · Post #979 · 11.01.2026 г., 08:05

International Youth Convention 2026 in Azerbaijan 🇦🇿 (Fully Funded) Apply: https://opportunitiescorners.com/international-youth-convention-in-azerbaijan/ Exceptional young Leaders from around the World are invited to apply. The program Covers Airfare, Meals, Accommodation. Deadline: 12 Jan 2026 #Azerbaijan#OpportunitiesCorners

Oğuz Eli

@oghuz_eli · Post #2168 · 05.03.2026 г., 23:16

Tehran molla rejimi dünən Naxçıvana PUA-ları atdı. Heç bir səbəbi olmadan əsassız yerə olan bir hücum. Srağagün Türkiyədə raketlə bir hücum olmuşdur. Mənə maraqlıdır ki, dırnaqarası "ağaya" yas saxlayanlar hansı bəhanə tapacaq? "İsrailin işi" mövzusu yalan və boş şeydir. Tək Tehran molla cumhuriyyətində olan PUA-ları İsrail ya Amerika necə ələ keçirə bilərdi? Həm də, molla rejimi hər dəfə Azərbaycana qarşı hücum eləməyə bəhanə axtarırdı. SEPAH-ın süni intellekt vasitəsi ilə düzələn qonşulara guya hədə-qorxu ilə gələn videoları yadınızdan çıxartdınız? Ya 2020-də Ermənistana hərbi yardımını? 2021-də Qarabağ hələ tam azad olunmayanda separatçılara yanacaq daşınan maşınlarını Azərbaycan Dövlət Sərhəd Xidmətinin qulluqçuları saxlayanda Azərbaycan sərhədlərinə yaxın öz ordularını təhdid üçün yeritməsini? Yoxsa 2023-cü ildə İranın dəstəyi ilə bir bişərəfin Azərbaycan səfirliyinə hücumunu? Ziya Bünyadovun satqın molla rejimin kölələri tərəfindən qətli və Fazil Mustafaya qarşı sui-qəsdi? Daha mən nəyi sizə deyim? Yoxsa siz "ağa" və "rəhbər" dediyiniz şəxsin Zəngəzur dəhlizinə qarşı olan mövqeyini bilmirsiz? Güneydə yaşayan soydaşlarımıza qarşı olan zülmdən xəbərsizsinizmi? Urmu gölünün qurumasından və molla rejimin bu məsələyə barmaqarası baxmasından xəbərsizsiniz? Yoxsa molla rejimin televiziya kanallarında və qazetlərində dilimizə "həşarat dili" və səfeh mollalar tərəfindən "türk dili cəhənnəmin dili" kimi ifadələrin deməsindən xəbərsizsiniz? Daha mən nəyi deyim? Cavab olaraq paylaşıma "ağamızın və İranın dini dəyərləri var" ifadəsini yazmayın. Ən azından dini dəyərləri olan ölkə Ramazan ayı vaxtı dinc dövlətə qarşı öz hücumlarını etmir və öz olkəsində bir şəxsin öz cinsini dəyişməyə icazəsini vermir. Bu paylaşımda İranın Azərbaycana qarşı yazdığım düşmənçilik siyasətin misallarından heç danışmıram. #Oğuz_Eli#Azerbaijan

123•••67
ПретходнаСтраница 1 од 7Следна