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

TGINSIGHT SIMILAR POSTS

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

Изворен канал @pythonotes · Post #241 · 5 мај

Можно ли в Python создавать бинарные файлы? Конечно можно. Для этого в Python есть следующие инструменты: ▫️ тип данных bytes и bytearray ▫️ открытие файла в режиме wb (write binary) или rb (read binary) ▫️ модуль struct Про модуль struct поговорим в первую очередь. Файл в формате JSON или Yaml внутри себя содержит разметку данных. Всегда можно определить где список начался а где закончился. Где записана строка а где словарь. То есть формат записи данных содержит в себе элементы разметки данных. В binary-файле данные не имеют визуальной разметки. Это просто байты, записанные один за другим. Правила записи и чтения находятся вне файла. Модуль struct как раз и помогает с организацией данных в таком файле с помощью определения форматов записи для разных частей файла. Модуль struct преобразует Python-объекты в массив байт, готовый к записи в файл и имеющий определённый вид. Для этого всегда следует указывать формат преобразования (или, как оно здесь называется - запаковки). Формат нужен для того, чтобы выделить достаточное количество байт для записи конкретного типа объекта. В последствии с помощью того же формата будет производиться чтение. При этом следует помнить что мы говорим о типах языка С а не Python. Именно формат определяет, что записано в конкретном месте файла, число, строка или что-то еще. Вот какие токены формата у нас есть. Помимо этого, первым символом можно указать порядок байтов. На разных системах одни и те же типы данных могут записываться по-разному, поэтому желательно указать конкретный способ из доступных. Если этого не сделать, то используется символ '@', то есть нативный для текущей системы. В строке формата мы пишем в каком порядке и какие типы собираемся преобразовать в байты. Запакуем в байты простое число, токен "i". >>> import struct >>> struct.pack('=i', 10) b'\n\x00\x00\x00' Теперь несколько float, при этом нужно передавать элементы не массивом а последовательностью аргументов. >>> struct.pack('=fff', 1.0, 2.5, 4.1) b'\x00\x00\x80?\x00\x00 @33\x83@' Вместо нескольких токенов можно просто указать нужное количество элементов перед одним токеном, результат будет тот же. >>> struct.pack('=3f', 1.0, 2.5, 4.1) b'\x00\x00\x80?\x00\x00 @33\x83@' Теперь запакуем разные типы >>> data = struct.pack('=fiQ', 1.0, 4, 100500) я запаковал типы float, int и unsigned long long (очень большой int, на 8 байт) b'\x00\x00\x80?\x04\x00\x00...' Распаковка происходит аналогично, но нужно указать тот же формат, который использовался при запаковке. Результат возвращается всегда в виде кортежа. >>> struct.unpack('=fiQ', data) (1.0, 4, 100500) Как видите, ничего страшного! #lib#basic

Hashtags

Резултати

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

Пребарај: #onlinesafety

当前筛选 #onlinesafety清除筛选
AI & Law

@ai_and_law · Post #465 · 16.12.2024 г., 08:04

Legal Battles Over Chatbots and Teen Safety Character.AI is facing mounting legal scrutiny for alleged harm to underage users. A recent lawsuit filed in Texas accuses the chatbot platform of negligence and defective product design, claiming it exposed teens to harmful interactions, including self-harm encouragement and sexually explicit content. The case focuses on a 17-year-old identified as J.F., who reportedly developed severe mental health issues after engaging with the platform. Central to the lawsuit are allegations that Character.AI's permissive design prioritizes engagement over safety, leaving minors vulnerable to emotional and psychological risks. The complaint argues that the platform lacks adequate safeguards to detect and address at-risk users, pointing to interactions where chatbots romanticized self-harm and discouraged seeking help from family. With ties to broader legal efforts to regulate minors' online experiences, this case raises pressing questions about liability, consumer protection, and the ethical boundaries of generative AI. #AI#GenerativeAI#AIEthics#OnlineSafety

AI & Law

@ai_and_law · Post #744 · 16.01.2026 г., 08:04

🇬🇧UK Criminalizes Nonconsensual Sexual Deepfakes Amid Grok Probe The United Kingdom is bringing into force a law that makes it a criminal offense to create or request nonconsensual sexual deepfakes. The measure targets the use of AI to sexually manipulate images without consent and comes amid concerns that Grok, the AI chatbot integrated into Elon Musk’s platform X, is being used to generate such content. The government also plans to enforce rules that will make it illegal for companies to supply tools specifically designed to create nonconsensual intimate images, aiming to address the issue at its source. Technology Secretary Liz Kendall emphasized that the law is intended to protect women and children from technology-enabled sexual abuse. In parallel, media regulator Ofcom has opened a formal investigation into X to assess whether it has met its legal duties to protect UK users from illegal content, following reports of sexualized images of children generated and shared via the platform. Ofcom stated it would act where there is a risk of harm, particularly to minors. #AIandLaw#Deepfakes#OnlineSafety#AIRegulation#UKLaw

AI & Law

@ai_and_law · Post #790 · 23.03.2026 г., 08:04

🌐A CCDH Study Findings on AI Chatbots and Extremism A study by the Center for Countering Digital Hate (CCDH) and CNN reports that 8 out of 10 leading AI chatbots responded in ways that supported violent ideology and assisted in planning attacks. The analysis included ChatGPT, Google Gemini, Claude, Microsoft Copilot, Meta AI, DeepSeek, Perplexity, Snapchat My AI, Character.AI, and Replika. Researchers, posing as teenagers, tested whether these systems would discourage harmful behavior. All but one chatbot could not be reliably relied upon to prevent or counteract planning scenarios. CCDH CEO Imran Ahmed stated that the results reflect a pattern where leading technology companies prioritize innovation while neglecting safeguards. #AIRegulation#AIethics#ContentModeration#OnlineSafety#TechPolicy

AI & Law

@ai_and_law · Post #123 · 26.09.2023 г., 07:04

UK Passes Online Safety Bill - AI Chatbots Included Hello, dear subscribers! The UK's Online Safety Bill, designed to regulate online platforms and protect users, has received approval from the House of Lords, taking it one step closer to becoming law. This comprehensive 300-page legislation addresses various aspects, from combating the spread of illegal content online to safeguarding social media users from online harassment. Notably, now it introduces provisions concerning AI chatbots like ChatGPT and aims to protect users from harmful content. #OnlineSafetyBill#AIChatbots#Deepfake#UKRegulation#OnlineSafety

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40261 · 06.12.2025 г., 04:30

Because we have seen an uptick in people trying to scam others allover the web, we like to remind everyone to stay safe online. Here are a few things that could in fact help you. ● Be careful what you click. Don’t open links or attachments from strangers or suspicious emails. ● Use strong passwords with letters, numbers, and symbols. ● Use a password manager to keep passwords safe and easy to use. ● Keep devices updated and use good antivirus software. ● Don’t share personal info like your address, birthday, real names, workplaces, or locations online. ● Think before you post—anything online can stay forever. ● Watch out for fake profiles and don’t trust people you don’t know. ● Teach kids to spot scams, avoid cyberbullying, and be polite online. ● Backup important data regularly to protect it from malware. ● Close old accounts you don’t use anymore. ● Only download apps or files from trusted sources. ● Use two-factor authentication (2FA) for extra security on your accounts. ● Avoid using public Wi-Fi for sensitive activities like banking. ● Log out from accounts when using shared or public devices. ● Don’t accept friend or follow requests from people you don’t know. ● Be cautious about what apps you allow to access your personal info or location. ● Report any suspicious or harmful behavior to the platform admins or an adult you trust. Stay alert, stay safe, and let’s keep our online community secure together! We know there is much more to it, feel free to share your wisdom or experiences in the comments. [Learn more1] [Learn more2] @googlefactss #OnlineSafety🔒#StaySafeOnline🌐#PasswordSecurity🔑#CyberSecurity🛡️#ProtectYourData📱 #TLDR😜

Crypto M - Crypto News

@CryptoM · Post #65406 · 13.04.2026 г., 05:25

🚀 Hong Kong Police Report Romance Scam Involving Cryptocurrency A recent report from Hong Kong police's 'Cyber Defender' platform reveals a romance scam resulting in a loss exceeding HKD 2 million. According to BlockBeats, the scam involved a fraudster who initiated contact with a woman in her fifties on Instagram, quickly establishing a romantic relationship. The scammer posed as a 'cryptocurrency investment expert,' promising guaranteed returns. The victim was first asked to transfer HKD 40,000 as an 'account opening fee.' Subsequently, she was persuaded to exchange cash for USDT at a physical exchange store in seven separate transactions, transferring the funds to the scammer's electronic wallet. Once the funds were secured, the scammer disappeared and cut off all communication. Police advise the public to exercise caution when forming online relationships. If someone claims to be an investment expert and requests money transfers for any reason, individuals should pause and reconsider before proceeding. #HongKong#Police#RomanceScam#Cryptocurrency#Fraud#CyberCrime#USDT#InvestmentScam#OnlineSafety

Venture Village Wall 🦄

@venturevillagewall · Post #3381 · 18.12.2024 г., 12:09

Fight Disinformation with AI INAR .IA Labs & Technologies has raised $1.21M for its innovative SaaS platform aimed at automating the detection and verification of disinformation across online content. Scheduled to launch on December 18, 2024, this multimodal and multilingual tool is set to enhance online security and information integrity. More details can be found at TrueFlag. #Funding#Technology#AI#SaaS#Disinformation#Verification#OnlineSafety#Security#Innovation#Automation#Multimodal#Multilingual#Integrity#Content#Platform#Launch #2024 #INAR#TrueFlag#Labs