Заметка начинающим, которые часто сталкиваются с подобной непоняткой.
Ситуация следующая, есть список файлов:
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
🌐Global Consensus Emerges on AI Data Security Standards
Four leading cybersecurity agencies — from the U.S., U.K., Australia, and New Zealand — have jointly released best practice guidance for securing data across AI system lifecycles. The focus: ensuring integrity, traceability, and resilience in AI training and deployment environments.
The document recommends practical safeguards such as digital signatures for trusted dataset revisions, provenance tracking, and the use of secure infrastructure. It also emphasizes proactive risk mitigation, calling for robust data protection strategies not just at the point of deployment, but from the earliest stages of model development.
#AI#DataSecurity#AIgovernance
Privacy at Stake: LegalShield Faces Lawsuit Over AI-Driven Call Interceptions
LegalShield, a prominent online legal services provider, is under fire as a class action lawsuit accuses the company of secretly intercepting and analyzing confidential client communications. The lawsuit claims that LegalShield failed to inform customers that their interactions would be routed through Talkdesk, a call center technology provider, which uses AI to listen, record, and analyze every word in real-time.
Talkdesk allegedly utilizes this intercepted data not just for enhancing customer service but also for its own purposes, including developing AI models. The lawsuit highlights the sensitive nature of the information at risk, such as credit card details and Social Security numbers, and suggests that clients would have refrained from engaging with LegalShield had they known about these practices.
This case underscores the growing concerns over privacy and the ethical use of AI in customer interactions, particularly in industries where confidentiality is paramount.
#AI#Privacy#DataSecurity#LegalTech
Give your e-waste a second life by recycling them this International E-waste Day 📱💻♻️
Find out more about how to recycle your e-waste at go.gov.sg/e-waste
Let’s also reduce the amount of e-waste generated by:
- Considering if you really need to buy new a product or if the current one can be repaired
- Choosing second-hand products over new products
- Donating devices that are in good condition to those who could put them to better use
#RecycleRight#RecycleOurEWaste#IEWD2024#InternationalEWasteDay2024#DataSecurity
Are your favorite Apps invading your privacy? Let's find out!
Artificial Intelligence has become a hot topic, raising questions about its impact on user privacy. Are AI apps really intruding on our personal data? A recent investigation by Home Security Heroes (HSH) reveals some eye-opening findings.
By examining various AI applications, HSH has uncovered the extent of data intrusion facilitated by AI technology. To determine the invasiveness of AI apps, HSH used the privacy labels available on the App Store. These labels reveal the amount of personal information an app tracks for marketing purposes. They evaluated a total of 159 apps.
Key Insights:
1️⃣ 75% of AI apps share users' data with third parties.
2️⃣ 64% of investigated AI-powered apps track users' personal data for their own marketing benefits.
The Most Invasive AI Apps:
🔹 Tracking 43% of personal data:
Brainly
Photoleap: AI Art Photo Editor
🔹 Tracking 36% of personal data:
Google Assistant
Socratic by Google
DaVinci – AI Generated Art
Facetune AI Photo/Video Editor
How comfortable are you with AI apps tracking and sharing your personal data? Are the benefits worth the potential risks to your privacy?
#AI#Privacy#DataSecurity#UserProtection#AIApps
🚀 AI TRENDS | U.S. Officials Convene Wall Street Leaders Over AI Cybersecurity Concerns
U.S. Treasury Secretary Scott Bessent and Federal Reserve Chair Jerome Powell have called an urgent meeting with Wall Street leaders to address concerns about the potential cybersecurity risks posed by the latest AI model from Anthropic. Bloomberg posted on X, highlighting the growing apprehension among financial regulators regarding the implications of advanced AI technologies on the security of financial systems.
The meeting underscores the increasing focus on AI's role in cybersecurity, as financial institutions grapple with the challenges of integrating cutting-edge technologies while safeguarding sensitive data. The Anthropic AI model, known for its advanced capabilities, has raised alarms about its potential misuse in cyberattacks, prompting federal officials to seek input from industry leaders on mitigating these risks.
This development comes amid a broader dialogue on the balance between technological innovation and security, as AI continues to transform various sectors. The discussions are expected to explore strategies for enhancing cybersecurity measures and ensuring that AI advancements do not compromise the integrity of financial systems.
#AI#Cybersecurity#WallStreet#Finance#Anthropic#USOfficials#Technology#Innovation#DataSecurity#FinancialRegulation
🚀 Telegram CEO Criticizes WhatsApp's Encryption Practices
Telegram CEO Pavel Durov has criticized WhatsApp's end-to-end encryption, labeling it as a 'massive consumer fraud.' According to ChainCatcher, Durov highlighted that approximately 95% of private messages are stored in unencrypted backups on Apple and Google servers.
Durov expressed concerns that this situation poses a risk to user privacy. Despite WhatsApp's claims of using end-to-end encryption for message transmission, the backup mechanism fails to ensure complete encryption of user information. His remarks have sparked industry attention regarding privacy protection measures in mainstream communication applications.
#Telegram#WhatsApp#Encryption#Privacy#DataSecurity#PavelDurov#CyberSecurity#MessagingApps#TechNews#EndToEndEncryption
🔐 Is Your Data Secure? 🔐
🫰 Discover peace of mind with #Cloudatabox – the #future of #secure, #decentralized storage powered by innovative #Web3 solutions! 🌐✨
🚀Register Now to explore how Cloudatabox keeps your data protected and accessible like never before. 📂🔒
Secure your future, secure your data!
#Cloudatabox#DataSecurity#Web3Solutions#DecentralizedStorage#RegisterToday#FutureOfStorage
🚀 Heart South Reports Potential Data Breach Affecting Thousands
Heart South has announced that approximately 46,666 individuals may have been affected by a data breach, with patient information from its network appearing on the dark web. According to NS3.AI, the company has been unable to verify if any specific individual's data was compromised. Notifications regarding the potential breach began being distributed in April 2026.
#HeartSouth#databreach#patientdata#darkweb#NS3AI#privacy#cybersecurity#datasecurity#breachnotification#April2026
🚀 Pavel Durov Highlights Privacy Risks of Push Notifications
Pavel Durov has raised concerns about the privacy implications of push notifications. According to NS3.AI, Durov pointed out that message data can persist in notification logs, posing a privacy risk even after messages or apps are deleted. He referenced a report by 404 Media, which revealed that the FBI was able to retrieve deleted Signal messages from an Apple iPhone by accessing these notification logs.
#PavelDurov#Privacy#PushNotifications#DataSecurity#Signal#iPhone#FBI#DigitalPrivacy#NotificationLogs#CyberSecurity