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

Резултати

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

Пребарај: #holdcoin

当前筛选 #holdcoin清除筛选
Holdcoin Channel

@Holdcoin_Channel · Post #360 · 01.01.2025 г., 12:17

#Holdcoin New Year Gift is Here! 🚨 Join HoldCoin and HOLD onto your New Year luck! 🏆 🤔Block Challenge: Which"crypto block"can clear the most lines? Leave your answer in the comments section of the link below, and don’t forget to include your game ID and TG username!‼️ https://x.com/holdcoingo/status/1874428330965168600?s=46 We’ll select 30 lucky players to receive 50 stars as a reward!!! ⬆️⬆️

Hashtags

Holdcoin Channel

@Holdcoin_Channel · Post #358 · 27.12.2024 г., 15:11

#Holdcoin coin Future Guidance 💎 💎 🌟The roadmap illuminates the future journey, from functional innovation to territorial expansion, leading to the grand vision of comprehensive ecological prosperity! ‼️ Let's move on together Holding = rich!🫴🫴 Season 2 airdrop is coming !🚀

Hashtags

Holdcoin Channel

@Holdcoin_Channel · Post #291 · 26.11.2024 г., 09:44

♾#HoldCoin Pre-Trade Now Live on CoinEx!🚨 CoinEx, a globally renowned digital asset trading platform, is now offering you the pre-trade opportunity for $HOLD! Seize this rare chance and become a pioneer!⚡️🌟 ⏰Start Time: November 25, 2024 ⚖️ Services: Pre-minting & Trading 🛍 Important Reminder: Make sure your wallet is ready, understand the trading details, and stay tuned to CoinEx for updates — don’t miss any important information! More Details📥 🗳 Announcement:https://t.co/9zFQUlGTwy ⛏️ Pre-mint:https://t.co/USH0CMUSeA 📲 Trade:https://t.co/N86rhANMdK Thank you for your support and trust. Take action now and join CoinEx to start the new era of #HoldCoin!🚀🚀

Hashtags

Holdcoin Channel

@Holdcoin_Channel · Post #289 · 25.11.2024 г., 09:44

💎#HOLDCOIN AIRDROP FRENZY IS COMING!🔥🔥 🎉 Dear holders, we are thrilled to announce that the $HOLD project is about to launch its pre-trading phase—an opportunity you simply can’t miss!💎 🔭 Pre-Trading Date: November 25th, officially kicking off on the Gate.io platform!💼 🐳 How to Participate: ✨ Ensure your wallet is ready. ✨ Carefully review the trading details to avoid any issues. ✨ Stay updated with Gate.io announcements for the latest information! 🏃‍♂️ Learn More: https://www.gate.io/zh/announcements/article/40993 https://www.gate.io/zh/pre-market/HOLD Let’s embrace this new chapter of #HoldCoin and work together to drive the project’s success! 👍😃

Hashtags

Holdcoin Channel

@Holdcoin_Channel · Post #252 · 26.09.2024 г., 12:54

⚡️⚡️⚡️⚡️⚡️⚡️ 👉The HoldCoin white paper is officially released, revealing the grand plans and exciting vision for HoldCoin’s future! Click the link below to dive into all the details—this is something you don’t want to miss! 💥 https://drive.google.com/file/d/1bAJfC3HWyUYooBjyfBB8fT1w8h3CTGfC/view?usp=sharing 🕯 Stay Hold-ready and seize this once-in-a-lifetime opportunity—wealth is on the horizon! 💪 #HoldCoin's journey to wealth is accelerating—keep up, and don’t miss your moment of glory! 📈📈 Additionally, The airdrop plan is about to be officially released—act fast and seize the advantage! 🚀

Hashtags

Holdcoin Channel

@Holdcoin_Channel · Post #230 · 10.09.2024 г., 06:17

⭐️Showcase Your HoldCoin Achievements⭐️ 🫡 The HoldCoin community is growing rapidly, attracting more users from around the world. 😎Now is your time to shine! Share your gold and diamond counts and show off your Hold power! Participation details: 📸 Post a screenshot of your HoldCoin game assets 🏷 Use the hashtag #HoldCoin 💬 Leave your game ID in the comments ✨ We will randomly select 50 lucky players, each winning 1,000 diamonds! 💰 Hold is victory! Become a wealth hero in HoldCoin and start your legendary journey today! 💪

Hashtags

Holdcoin Channel

@Holdcoin_Channel · Post #308 · 11.12.2024 г., 03:19

🚨#MEXC New Listing Alert! 📈 $HOLD/USDT will be listed in the Innovation Zone on 2024-12-16 13:00 (UTC). In the crypto asset management simulator game #HoldCoin, which is based on Telegram, users can HOLD assets and create a portfolio to generate coins. Details: https://www.mexc.com/support/articles/17827791520405

Holdcoin Channel

@Holdcoin_Channel · Post #261 · 09.10.2024 г., 09:03

💎#HoldCoin is taking the world by storm! 🔥 Major media outlets like Cryptoate, Cryptomanias, Geekocoin, Digital Journal, and Benzinga have all reported on HoldCoin. 💎 Does this mean some big events are just around the corner? 🐂 Keep holding #Hold! Follow our channel and X to get the latest updates on the TGE as soon as they drop! 🚀

Holdcoin Channel

@Holdcoin_Channel · Post #219 · 03.09.2024 г., 04:42

🚀 TON Fest Season 1 heats up with HoldCoin🎉 💥Win 6 Million Diamonds & $TON 🔥The longer you “hold”, the more you are rewarded 📆Sept 3-Sept 8, 4 AM UTC 👉HoldCoin mini app Open SafePal App QuestHub to join the campaign now! 📱DL App: http://safepal.com/download 📚Learn more campaign detail #SFP#TonFest#HoldCoin

Holdcoin Channel

@Holdcoin_Channel · Post #54 · 18.06.2024 г., 07:24

💎 HoldCoin - 🐟 TonFish Joint Giveaway Complete tasks to win big prizes! 🎁💵HoldCoin and Ton Fish are excited to announce an incredible giveaway. Anyone can participate, so don't miss this perfect chance to win astonishing rewards! 🗓 Timing: June 18th at 00:00 - June 22nd at 24:00 (UTC) ☄️ How to participate: - Join the HoldCoin game - Follow Ton Fish - Follow HoldCoin - Like, retweet this post (https://x.com/HoldCoinGo/status/1802965219297349981) and tag 3 friends, using hashtags #HoldCoinGo#HoldCoin#TonFish#Fish 💰Complete the above tasks to enter, and we will select 50 users to receive an airdrop of 100,000 $HOLD. 🤜Invite friends to the HoldCoin game to earn an unlimited amount of $HOLD. Join now and claim your rewards immediately! 💥 Play the game 👉@theHoldCoinBot (https://t.me/theHoldCoinBot/app)