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

Резултати

Пронајдени 1,312 слични објави

Пребарај: #airdrop

当前筛选 #airdrop清除筛选
Legit Airdrop ❤️

@legit365airdropss · Post #36069 · 02.03.2026 г., 12:53

✉️Konnex Airdrop 🔸Reward: Confirmed ✅Register: https://hub.konnex.world/points?referral_code=AP40WF8P 🔸Connect Wallet 🔸Complete Tasks 🔸Done #Airdrop

Hashtags

Legit Airdrop ❤️

@legit365airdropss · Post #36046 · 27.02.2026 г., 06:28

✉️Konnex Airdrop 🔸Reward: Confirmed ✅Register: https://hub.konnex.world/points?referral_code=AP40WF8P 🔸Connect Wallet 🔸Complete Tasks 🔸Done #Airdrop

Hashtags

Airdrop Center

@centralchanel · Post #17289 · 17.05.2025 г., 19:24

📢 L1 project has $8,000,000 investment @pharos_network Let's be early for the approved #airdrop with the Testnet of the project! 💰 Cost: $0 ⌛️ Duration: 5 min. Take your place for this approved airdrop with our guide! 👇 📝 Airdrop transactions We will directly do the Testnet transactions of the project. 👇 🔗https://testnet.pharosnetwork.xyz/experience?inviteCode=0r2VJZpIPZ3Q84hh ➤ Connect your wallet with the Connect Wallet button and approve the addition of the testnet network. ➤ Scroll down on the homepage and complete the social tasks by connecting your social media accounts by pressing the follow button first. ➤ Then click on the Home button from the top left and scroll down to get test tokens from the faucet. ➤ Return to the Experience tab again and this time complete tasks such as Swap, adding liquidity (connect the wallet on the websites it directs and perform transactions from the relevant headings.) ➤ Leave the wallet you used for the testnet in the comments and let's send each other test tokens to complete the 3rd task. ➤ Finally, share your own invite links with friends.

Hashtags

Airdrop Center

@centralchanel · Post #16502 · 10.02.2025 г., 07:55

💵 Mevvynetwork Waiting List 💥A total of $2,800,000 investment was received. Join the project's waitlist and take your place for #airdrop now! 💥We will quickly join the project's waitlist and take our place as early birds. → Registration: https://mevvynetwork.com/waitlist?referralCode=dxan1dx&refSource=copy → Enter your e-mail address and confirm → Click the Join waitlist button and invite friends with your own invitation link

Hashtags

Airdrop Center

@centralchanel · Post #16016 · 13.01.2025 г., 10:18

🪂 High Potential Airdrop - Bubblemaps 🪂 Quickly take your place for #airdrop with the transactions of the @bubblemaps project that we use to follow smart money! 🚀 Cost: $0 💰 Duration: 5 Sec. ⌛️ 📝 Airdrop Transactions The project has started a waitlist, let's join quickly and take our place early. → First, go to bubblemaps.io/waitlist. → Then leave your email address. → Press the pink arrow button and send. ✔️ That's all the transactions. Don't forget to follow the official X account of the project! With our guide above, you have positioned yourself early for the approved airdrop!

Hashtags

🎁Airdrops Info🎁

@crypdrops · Post #9304 · 22.10.2024 г., 18:36

Probably making $0 Transaction narratives might get started fully on @ton_blockchain Soon! Get started with this #Airdrop before others jump to this narratives on $Ton! Introducing @keyytton#Airdrop! 📌Send 0 TON to the wallet address below 👇 UQB0ZszlqU7eabz_dyYfIAKsZ0F-U8b4iwJ1cTuePWIqipjA for the $KEY $Airdrop. 🔓 your reward in November. Season 1 ends on November 1st & TGE. Noted: Don't connect your wallet just send 0 Ton. Enjoy!

Hashtags

123•••100•••109110
ПретходнаСтраница 1 од 110Следна