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

Резултати

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

Пребарај: #addiction

当前筛选 #addiction清除筛选
蛋挞报

@Pincongessence · Post #2491 · 04.11.2021 г., 03:12

当我们过度沉迷游戏或社交媒体以致无法按时完成某项工作,或是想要学习某项新技能却总是在实践阶段动力不足时,不妨先放下“缺乏自控力”或是“意志力不够强”这类自我批评。从生理学和行为学的角度了解成瘾的机制,可以帮助我们以更清醒的方式规划生活,朝着既定的目标前进。 Dopamine Detox:How I Tricked My Brain To Like Doing Hard Things #video#dopamine#addiction#detox

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40622 · 03.02.2026 г., 15:02

Some studies found that watching a lot of (internet)pornography can change the brain. Brain scans showed stronger links in areas that control emotions and decisions. People who watch often feel more pleasure but have less self-control. After watching, their thinking and attention get worse. Their facial expressions also show less emotion, like surprise or disgust, even if they say they enjoyed it. These changes are similar to drug addiction. Repeating this behavior can make emotional responses dull and reduce mental sharpness. More research is needed, but finding people who never watched porn for studies is very difficult to impossible.. 🧠📉 [Read more1] [Read more2] [Read more3] [How to stop watching] @googlefactss #BrainHealth#Addiction#Pornography#porn#MentalHealth#Neuroscience 👮‍♂🚫Warning: Even though this post and the following poll are sexual in nature. Rules still apply. Be respectful or face the consequences..

American Оbserver

@american_observer · Post #5474 · 26.03.2026 г., 01:59

Meta, YouTube and the First Cracks in Big Tech’s Legal Armor Meta and YouTube just lost the “we’re just a platform” myth in court. A jury looked at their design tricks and called them what they are: engineered addiction for kids. In Los Angeles, jurors found Meta and YouTube negligent and awarded $3 million to a young woman, K.G.M., who said she was pulled into Instagram and YouTube as a child and ended up with anxiety and depression. Her lawyers didn’t argue about a bad post or a rogue comment; they went after the architecture — endless scroll, engagement loops, notification hooks — as a product defect, not a speech issue. The verdict landed 24 hours after a New Mexico jury ordered Meta to pay $375 million in civil penalties for deceiving parents and endangering children, finding the company put profits over safety and misled the public about harms. Two juries, two states, same message: Section 230 won’t save you if the claim is “you built an addiction machine,” not “someone posted something nasty.” And this is only the opening salvo. There are more than 2,400 similar cases pending in federal litigation against Meta, Google, TikTok and Snap, brought by teens, parents, school districts and attorneys general all arguing the same core point: the harm is in the design, not just the content. Silicon Valley thought it had legal armor; what it actually has is a growing line of juries ready to test how much that armor is really worth. #meta#youtube#socialmedia#addiction#lawsuits#kids#bigtech 📱American Оbserver - Stay up to date on all important events 🇺🇸

TikTok CEO Shou Chew on Its Future — and What Makes Its Algorithm Different | Live at TED2023 @TED TikTok CEO Shou Chew dives into how the trend-setting video app and cultural phenomenon works — from what distinguishes its algorithm and drives virality to the challenges of content moderation and digital addiction. In a wide-ranging conversation with head of TED Chris Anderson, he tells stories about the TikTok creators he loves and digs into thorny issues like data privacy and government manipulation — as well as speaking personally about his commitment to inspiring creativity and building community. #YouTube#liked#TEDTalk#TEDTalks#TED_Talk#TED_Talks#TED#TikTok#Shou_Chew#culture#technology#business#entreprenuer#entertainment#media#software#innovation#communication#product_design#AI#social_media#Internet#governement#data#addiction#machine_learning#UX_design#online_privacy