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

Резултати

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

Пребарај: #adsgram

当前筛选 #adsgram清除筛选
TONlines – News

@tonlines · Post #7698 · 03.12.2025 г., 16:34

⚡️Trending Apps: TON Nest and AdsGram Developer Workshops #TON#Telegram#AdsGram Trending Apps shares that TON Nest, in partnership with AdsGram and the TON Foundation, is launching a webinar series for teams developing Telegram Mini Apps. Starting tomorrow, the program will offer in-depth sessions on marketing, monetization, and user acquisition, accessible via Zoom and livestreams on YouTube and X. Source: link @tonlines

Gemi Faucet News

@gemifaucet · Post #771 · 10.02.2026 г., 07:09

💥 OFFICIAL PARTNERSHIP ANNOUNCEMENT 💥 We’re pleased to announce an official partnership between Gemifaucet and AdsGram, focused on improving monetization quality and user experience across our platform. 🚀 About Gemifaucet Gemifaucet is a Telegram mini app where users receive rewards by interacting with tasks and ads in a simple, transparent, and user-friendly environment. 📊 About AdsGram AdsGram is a leading Telegram Native Ads platform trusted by top Telegram apps and communities. It provides seamless, non-intrusive ad solutions with strong performance, advanced analytics, and a proven monetization ecosystem. 🤝 Why this partnership matters By this official partnership formalizes our collaboration and strengthens our monetization infrastructure. 👉 Gemifaucet: @gemifaucet_bot 👉 AdsGram: @adsgram_ai Thank you for your continued support — more updates coming soon! 🚀 #OfficialPartnership#Gemifaucet#AdsGram#TelegramMiniApp#Announcement

October 31, Dubai 😀 Telegram Builders Day Friendly reminder — on October 31, Dubai will host the Telegram Builders Day organized by the @epicweb3 and @ton_tongames🧞‍♂️ @epicweb3 is known for creating events for blockchain builders around the globe, and this will be their debut in the Telegram ecosystem! Get ready to hear from speakers representing #Notcoin, #TonTon Games, #Catizen, #StormTrade, #Blum, #Adsgram, #Fanzee Battles, #LayerPixel, and #Adsonar, who will discuss user acquisition, attracting investments, launching successful viral projects, and the future of the ecosystem. Tickets are FREE, but limited, so hurry up — this is the place to be! 🎟✨ #TON#networking#web3

🐓✨Tencent PP Ranch✨

@tencentppranch012 · Post #220 · 20.10.2024 г., 11:51

💎I wish you all a happy weekend! Let go of your worries and enjoy these beautiful days! 💎Do you have any good plans for next week? 💎If not, expand the chicken farm bigger and bigger, so that money can flow in like eggs! Achieve financial freedom as soon as possible, let's "chickens" fly and "chickens" jump together, and turn ourselves into wealth masters! 🎁In addition, friends who have not entered the global Tencent official channel to receive the bonus and welfare red envelope, don't worry, I have sent you a tutorial, go and check it out! 💎I hope my blessings can relieve everyone's pressure. #TONVentures#GateVentures #MEXCVentures#KeneticCapital #ForesightVentures#CurveFinance#MEXCVentures#Adsgram#Yescoin#CurveFinance#Invest#WealthBuilding#FinancialFreedom#Crypto#Blockchain#Decentralization #MarketTrends#Trading#Analysis #PassiveIncome#RealEstate#InvestmentPortfolio #Stocks #Tencent PP Ranch #FreeTrial #Farm Game #Earn USDT #Play with Friends 🎮 Game Assistant 🤖Game Bot ⌨Discussion Group🤩VIP Channel 🪙 Join the Game Now