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

Резултати

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

Пребарај: #presale

当前筛选 #presale清除筛选

​​🎙 INVEST REPORT Injex Finance - The 1inch of Injective 🔥🥷 ⚖️ INVEST REPORT project rating 9/10 ⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️ It is the final day of Round 1 in $INJX Presale, and this is your moment to act before the price jumps. Join Presale: https://sale.injex.fi/ Don’t let this chance slip through your fingers! Secure your $INJX tokens now at the most favorable price. Join the future of decentralized finance on the Injective chain. Act now, join the presale. https://sale.injex.fi/ #INJ#Presale

Hashtags

Airdrop Strikers™

@airdropstrikers · Post #660 · 28.09.2022 г., 12:10

#PoshCoin#Presale Public Presale Started NOW! ℹ️ Info About PoshCoin: PoshCoin is a new crypto token that will revolutionize the digital economy – mainly selling and purchasing goods in the cannabis sector. PreSale Link:https://www.pinksale.finance/launchpad/0xD90267576273A0d640850De1beFdF366744C13DB?chain=BSC ⚜️ Token Information 🔶Token Name: Poshcoin 🔶 Symbol: PSCN 🔶Type: BEP-20 🔶 Minimum Buy: 0.0035BNB 🔶 Maximum Buy: 35BNB 🌐 Useful links : Telegram Channel Platform: https://t.me/PoshCoinPSCN Telegram platform group: https://t.me/poshcoin_pscn JOIN PRESALE NOW! Disclaimer: Please do your own research before joining to any project.

Airdrop Strikers™

@airdropstrikers · Post #583 · 01.09.2022 г., 13:53

#MetaCubez#Presale A Metaverse Full of Possibilities ✔️ Licenced From Singapore and UAE ✔️ Audited Smart Contract ✔️ KYC Team ✔️ 30% Burnt ✔️ 60% Locked ✔️ Professional team from all around the world MetaCubez Pre-Sale is Live Now!🔥🔥 https://linktr.ee/MetaCubez Check out there Social Links Channel | Community | Website | Instagram | Discord | Twitter

Airdrop Market Pro

@airdrop_market_pro · Post #361 · 29.03.2023 г., 00:06

🚨🚀 Exciting news for all crypto enthusiasts! 🌟🤑 🚨🚀 25% of DLX tokens will be available for pre-sale on Pinksale Finance from April 25-30, 2023. This is a rare opportunity to invest in one of the hottest tokens on the market! #PinksaleFinance#presale💰💸💎 Hey all you crypto enthusiasts! We've got some awesome news to share - the pre-sale for DLX tokens on Pinksale Finance is starting soon! From April 25-30, 2023, 25% of the total DLX token supply will be available for purchase. Don't miss out on this chance to invest in one of the hottest tokens on the market! #PinksaleFinance#presale💰💸💎 🔥👇 Web site Dollex Network https://dollox.network/ ‼️Note: We are airdrop hunters and only participate in free airdrops, please do not send any fee for receiving airdrop tokens.

NFT & Airdrop News

@airdrop_nft1 · Post #360 · 29.03.2023 г., 00:06

🚨🚀 Exciting news for all crypto enthusiasts! 🌟🤑 🚨🚀 25% of DLX tokens will be available for pre-sale on Pinksale Finance from April 25-30, 2023. This is a rare opportunity to invest in one of the hottest tokens on the market! #PinksaleFinance#presale💰💸💎 Hey all you crypto enthusiasts! We've got some awesome news to share - the pre-sale for DLX tokens on Pinksale Finance is starting soon! From April 25-30, 2023, 25% of the total DLX token supply will be available for purchase. Don't miss out on this chance to invest in one of the hottest tokens on the market! #PinksaleFinance#presale💰💸💎 🔥👇 Web site Dollex Network https://dollox.network/ ‼️Note: We are airdrop hunters and only participate in free airdrops, please do not send any fee for receiving airdrop tokens.

Airdrop Strikers™

@airdropstrikers · Post #504 · 22.07.2022 г., 14:37

#SVC#presale#Sponsored 💎Smart Vision Coin Public Presale is now LIVE 💎Presale Link : https://www.pinksale.finance/launchpad/0x662Da19fDeF9B8B23636dDBfcDDd63013eE00911?chain=BSC ✅Token Name: Smart Vision Coin (SVC) ✅Token Address:0xAAc82B1d9fFE7c50fd2d5C8b0d3a0d8E3a374b03 ⏲Presale Time: 07/21 06:00AM ⏲Ends Time: 08/20 23:59PM 💰Soft/Hard Cap: 1,500 BNB / 3,000 BNB 💰Min/Max: 0.01 BNB / 10 BNB 💰Presale Rate: 1 BNB = 3,800,000 SVC 💰Listing Rate: 1 BNB = 2,300,000 SVC 🔓Liquidity: 51% 🔓Liquidity Lockup Time: 365 days 👉Telegram: https://t.me/svc_coin 👉Telegram Channel: https://t.me/svc_coin_channel 👉Twitter: https://twitter.com/svc_coin 👉Website: https://www.smartvisioncoin.net/

Airdrop Market Pro

@airdrop_market_pro · Post #1386 · 02.10.2025 г., 15:08

💎 MetaGram Presale — Early Investors’ Edge! Be among the first to secure $MGR before listing at $0.0519. ⚡️ Buy & Earn instantly with our new swap-style UI: 0.001 BNB → 50 $MGR (free airdrop) 0.01 BNB → 500 $MGR 🤝 Referrals: +50% $MGR & +50% BNB back 🔥 Early entry = maximum upside. Don’t wait until the price goes public. 👉metagram.digital #MetaGram#Presale#BNB#Crypto

Airdrop Market Pro

@airdrop_market_pro · Post #1385 · 01.10.2025 г., 20:18

We’ve refreshed the MetaGram presale page! New swap-style UI = faster, clearer, mobile-friendly buying. 🚀 Don’t miss the Presale & Airdrop 💎 0.001 BNB → 50 $MGR (airdrop) ⚡️ 0.01 BNB → 500 $MGR 🤝 Referrals: +50% $MGR & +50% BNB 🔥 Listing price: $0.0519 / MGR 👉https://metagram.digital/airdrop #MetaGram#BNB#Presale#Crypto

Airdrop Market Pro

@airdrop_market_pro · Post #1383 · 29.09.2025 г., 16:38

We’ve refreshed the MetaGram presale page! New swap-style UI = faster, clearer, mobile-friendly buying. 🚀 Don’t miss the Presale & Airdrop 💎 0.001 BNB → 50 $MGR (airdrop) ⚡️ 0.01 BNB → 500 $MGR 🤝 Referrals: +50% $MGR & +50% BNB 🔥 Listing price: $0.0519 / MGR 👉https://metagram.digital/airdrop #MetaGram#BNB#Presale#Crypto

NFT & Airdrop News

@airdrop_nft1 · Post #1382 · 02.10.2025 г., 15:08

💎 MetaGram Presale — Early Investors’ Edge! Be among the first to secure $MGR before listing at $0.0519. ⚡️ Buy & Earn instantly with our new swap-style UI: 0.001 BNB → 50 $MGR (free airdrop) 0.01 BNB → 500 $MGR 🤝 Referrals: +50% $MGR & +50% BNB back 🔥 Early entry = maximum upside. Don’t wait until the price goes public. 👉metagram.digital #MetaGram#Presale#BNB#Crypto

NFT & Airdrop News

@airdrop_nft1 · Post #1381 · 01.10.2025 г., 20:18

We’ve refreshed the MetaGram presale page! New swap-style UI = faster, clearer, mobile-friendly buying. 🚀 Don’t miss the Presale & Airdrop 💎 0.001 BNB → 50 $MGR (airdrop) ⚡️ 0.01 BNB → 500 $MGR 🤝 Referrals: +50% $MGR & +50% BNB 🔥 Listing price: $0.0519 / MGR 👉https://metagram.digital/airdrop #MetaGram#BNB#Presale#Crypto

NFT & Airdrop News

@airdrop_nft1 · Post #1379 · 29.09.2025 г., 16:38

We’ve refreshed the MetaGram presale page! New swap-style UI = faster, clearer, mobile-friendly buying. 🚀 Don’t miss the Presale & Airdrop 💎 0.001 BNB → 50 $MGR (airdrop) ⚡️ 0.01 BNB → 500 $MGR 🤝 Referrals: +50% $MGR & +50% BNB 🔥 Listing price: $0.0519 / MGR 👉https://metagram.digital/airdrop #MetaGram#BNB#Presale#Crypto

ПретходнаСтраница 1 од 5Следна