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

Резултати

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

Пребарај: #uxuy

当前筛选 #uxuy清除筛选
Airdrop Center

@centralchanel · Post #16337 · 30.01.2025 г., 04:56

➡️ UXUY Wallet ✅ PLAY NOW: https://t.me/UXUYbot/app?startapp=A_452308012_inviteEarn Invested by BinanceLab 👈 Ends on January 10 ⛔️ $10.2M in funding successfully raised 🟢 1️⃣Securely store your private key 2️⃣Complete all tasks 3️⃣ Claim rewards every 3 hours 👍 UXUY: Don’t forget to back up your seed phrase! ❓ "Not your keys, not your crypto!" 👉 The Seed Phrase Backup Task is live! Complete the backup and claim your reward of 800 $UP! #UXUY

Hashtags

🪙UXUY Wallet: Mysterious Airdrop When? TOMORROW, March 11, the project on Binance Labs investments #UXUY Wallet launches distribution, but there is an important condition: ✅UXUY wallet in Telegram needs to be created today!🔥 What needs to be done? ✔️ Hurry up to create a wallet before March 11 00:00 UTC. ✔️ Tell your friends — let them get a drop too! ✔️Follow the news! ☝️Create UXUY wallet now!

Hashtags

UXLINK

@uxlink_community · Post #18 · 31.10.2024 г., 03:10

🥰Good morning fams! We are pleased to announce that UXLINK Mini App is live on LINE , now invite your friends on Line to join #UXLINK can get 10,000,000 #UXUY points reward! In UXLINK's "One Account, One Gas" roadmap, $UXLINK will be the universal gas token for users who interact with different blockchains, and LINE and Kakao Talk will be important pillars of social platforms, will keep build and keep our community updated.

Hashtags

Super Airdrop from UXUY Wallet #UXUY, incubated and supported by 🤑 Binance Labs, is launching the 2025 UXUY Points ($UP) #Airdrop! 🗓️ Dec 27, 2024 — Jan 10, 2025 How to join? Invite three or more friends using your unique referral link ✅Go to the UXUY Earn Center ✅ Click on Tasks ✅ Complete them to earn UXUY Points ($UP) 🎁Join the event now and earn 2,025 $UP per user!

🔠🔠2025 New Year Special Airdrop Event ends in just 2 days! 🔣 Users who successfully invite 3 friends during the event period (December 27, 2024 — January 10, 2025) will receive an exclusive bonus of 2,025 $UP! 🔠🔠 Don’t miss out — get in there and rack up more $UP before it’s over! #UXUY#wallet#airdrop

UXUY Wallet: Redefining Cross-Chain DeFi UXUY is a platform (wallet and DEX) that provides tools and solutions for DeFi, focusing on multi-chain transactions and interoperability. The main focus of the project is to facilitate the process of exchanging assets between different blockchains (cross-chain), with an emphasis on security, speed and convenience. The project raised $10.2M in a funding round from well-known funds such as Binance Lab, KuCoin Ventures, MEXC and others. Key features of UXUY: 1. Multi-chain compatibility: The platform supports interoperability between multiple blockchains, including Ethereum, BNB Chain, Polygon, Arbitrum, Avalanche and 🤑 TON. 2. Decentralization: Users retain full control over their assets as transactions are conducted directly through smart contracts, eliminating intermediaries. 3. Intuitive Interface: UXUY is focused on making DeFi easier for users, including a simplified asset exchange process. 4. Focus on Security: State-of-the-art security mechanisms, including multi-layered transaction verification architecture, are used to protect user funds. UXUY Wallet Token – $UP The $UP token is a key element of the UXUY ecosystem. It will be used to pay exchange fees, provide access to premium platform features, serve as collateral in staking programs, and will also become a tool for DAO governance. The reward program has allocated 100 million UP, which will be distributed among the most active UXUY Wallet users. 🎁Complete tasks in the mini-app #uxuy#dex#airdrop#binance

Airdrop Center

@centralchanel · Post #15668 · 27.12.2024 г., 17:27

#Reminder UXUY WALLET 💎A project followed and supported by #Binance laps. 👀It has received high investments and its infrastructure is solid. The listing will probably not be extended. It conflicts with the logic of Claim Every 3 Hours. Link:⤵️ JOIN NOW https://t.me/UXUYbot/app?startapp=A_452308012_inviteEarn ⛏#uxuy#wallet#binancelaps

Airdrop Center

@centralchanel · Post #15821 · 04.01.2025 г., 20:20

January Listing 🔥 ✅#Nodepay: 6 January ✅#MomoAi: 6 January ✅#Xterio: 8 January ✅#Sidekick : 8 January ✅ $Vertus :13 January ✅#Seed : 15 January ✅#Xcoin : 20 January ✅#Tapswap : 23 January ✅#Wcoin : 25 January ✅#CommunityGaming : 28 January Unofficial Listing ✅#PAWS ✅#UXUY ✅#Yuligo ✅#MemeWar ✅#DuckChain ✅#Celia Stay connected