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

Резултати

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

Пребарај: #spokenenglish

当前筛选 #spokenenglish清除筛选
English With Natives*

@sirjimmy · Post #31229 · 23.10.2024 г., 07:31

🌹Spoken English🌹 When you watch something very impressive, you may say: 1 Everybody seems captivated by it😍 2 You seem mesmerized 🤩 3 I was moved to tears,actually 😪😍 4 That's a show stopper!👏👏👏👌 5 I can't take my eyes off of this😍 6 Wow! This is so spectacular!👏👏👏 7 This is breathtaking!😲🤩 #SpokenEnglish #TeamJimmy @SirJimmy

English With Natives*

@sirjimmy · Post #31045 · 22.04.2024 г., 05:40

🌹Spoken English🌹 When you watch something very impressive, you may say: 1 Everybody seems captivated by it😍 2 You seem mesmerized 🤩 3 I was moved to tears,actually 😪😍 4 That's a show stopper!👏👏👏👌 5 I can't take my eyes off of this😍 6 Wow! This is so spectacular!👏👏👏 7 This is breathtaking!😲🤩 #SpokenEnglish #TeamJimmy @SirJimmy

English With Natives*

@sirjimmy · Post #30804 · 08.11.2023 г., 06:46

🌹Spoken English🌹 When you watch something very impressive, you may say: 1 Everybody seems captivated by it😍 2 You seem mesmerized 🤩 3 I was moved to tears,actually 😪😍 4 That's a show stopper!👏👏👏👌 5 I can't take my eyes off of this😍 6 Wow! This is so spectacular!👏👏👏 7 This is breathtaking!😲🤩 #SpokenEnglish #TeamJimmy @SirJimmy

English With Natives*

@sirjimmy · Post #30752 · 15.10.2023 г., 06:16

💜Spoken English💜 1 We are all square/ We are even= if two people are square, one of them has paid off a debt to the other and neither now owes or is owed any money 💰 2 Vibes- a person's emotional state or the atmosphere of a place that is felt by others: He is always giving off good vibes🧚‍♀ 3 Give it a rest!= It's enough!/ Stop it!🙅🏻‍♀ 4 to catch someone off guard 💂‍♂️When you caught someone doing something and it was very unexpected 5 Take it with a grain of salt 🧂= to understand that something is likely to be untrue or incorrect #SpokenEnglish #TeamJimmy @SirJimmy

English From Zero to Hero

@Learn_English_from_Zero_to_Hero · Post #60262 · 16.09.2025 г., 07:19

#SpokenEnglish #usefuIlanguage 💥"I'm only razzing you!" ⚡️This phrase is often used in informal contexts to indicate that someone is joking or teasing another person in a playful manner. It suggests that the teasing is not meant to be taken seriously or to hurt feelings. ⚡️If a friend playfully mocks your choice of movie, you might respond with, "Oh, come on! I'm only razzing you!" 💥 "You do you!" ⚜This expression is a way of encouraging someone to be themselves and to pursue their own interests, choices, or lifestyle without worrying about what others think. It promotes individuality and self-acceptance. ⚡️If someone is hesitant about wearing an unconventional outfit, you might say, "Hey, if you like it, you do you!" 💥"The credits roll, but the story lingers." ⚜This phrase suggests that even after an event has concluded (like a movie ending with credits), the impact or essence of the experience continues to resonate or affect people. It implies that stories, emotions, or lessons learned endure beyond their immediate context. ⚡️ After finishing a powerful film, you might reflect, "The credits roll, but the story lingers in my mind long after."

1 English learning materials

@englishmeta1 · Post #108 · 31.03.2022 г., 10:11

Rumor has it that 'Rumor has it' is an expression used when suggesting you might have heard something or read about something that is taking place now or in the future. A rumor is not a fact. 🖱, "Rumor has it that the player will get traded." 🖱, "Rumor has it that she cheated on him." 🖱, "Rumor has it that they are going to get married." 🖱, "Rumor has it that you like to paint." 🖱, "Rumor has it that show is going to end." 🖱, "Rumor has it that your sister got in trouble." 🖱, "Rumor as it that she goes to our gym." #spokenEnglish #phrases #teamjimmy #sirjimmy

BBC Learning English

@english_bbc_learning · Post #3912 · 08.02.2026 г., 08:19

Let’s be real: You’ve probably seen a list like this 1,000 times. It looks repetitive, maybe even "dumb." But here is why it actually matters for you: When you only have one word for everything (like "Good"), your brain "glitches" when you're trying to speak fast. You hesitate because you're searching for variety but your "vocabulary folder" is empty. 🧠 The Secret to Speaking Fast:🛫 Fluency isn't about knowing the hardest words; it's about having options. When you have 3-4 ways to say the same thing, your brain doesn't have to stall. It just picks the next available word and keeps the flow going. - #English#SpeakEnglish#EnglishTips#Vocabulary#SpokenEnglish