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

Резултати

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

Пребарај: #cryptocurrency

当前筛选 #cryptocurrency清除筛选
The Hacker News

@thehackernews · Post #8826 · 18.04.2026 г., 08:00

Sanctioned #cryptocurrency exchange Grinex is shutting down after a $13.74M hack. Stolen funds were quickly moved and swapped to avoid freezing. The platform is linked to Garantex, flagged for laundering over $100M. 🔗 Read → https://thehackernews.com/2026/04/1374m-hack-shuts-down-sanctioned-grinex.html

🦅 [ perspective ix ]

@perspectiveix · Post #1281 · 20.05.2018 г., 19:30

​​💰With at least $1.3 billion invested globally in 2018, VC funding for blockchain blows past 2017 totals 🚀@PerspectiveIX Read more at t.me/iXNews/25659 Do you own any #CryptoCurrency? 👍🏻 Yes 😅 No, but I'm thinking of buying 👎🏻 No, not interested at all

DWF Labs Broadcast

@Dwflabs · Post #183 · 27.01.2023 г., 03:05

Fans of the TON #cryptocurrency now have a new way to trade their favorite altcoin following its addition to the options trading markets on the popular exchange platforms BIT and Paradigm. The options are live on the platform today and will be available on the institution-focused liquidity network Paradigm later, the exchange said in a statement shared with CoinDesk. The options are launched in collaboration with liquidity provider Darley Technologies and blockchain industry market maker and TON-backer DWF Labs. "Joining the options market is a logical and important step for TON because, until now, the only coins available there were BTC and ETH. It means TON will take its place alongside crypto's most prestigious coins," said Andrei Grachev, Managing Partner at DWF Labs. Full read here: https://lnkd.in/g6zACNN7

🗺 Travel the World | Private Expeditions

@expeditionsworldwide · Post #52 · 12.08.2020 г., 04:30

📊Intermediate statistics for the experimental portfolio: Days elapsed since launch: 20; Purchased 18 coins: #BTC #XRP #REP #EOS #NEO #STRAT #BSTX #OGN #ETC #ICX #LTC #CELR #QTUM #DASH #BEAM #LTO; Already Invested (since launch): $200 Total profit (since launch): 7.02% 📊Detailed portfolio statistics - https://bit.ly/30GlvN2 ➕FIBONACCI $10 Experiment (#cryptocurrency)

Trump's Ear

@trumpsear_tg · Post #1448 · 02.09.2025 г., 13:59

Trump earned more in cryptocurrency in a day than in real estate in his entire life - The Wall Street Journal On September 1, the WLFI token, another cryptocurrency issued by the Trump family, began trading on exchanges. The price of the token on the first day of trading fell by more than a third from its peak value, but despite this, the Trump fortune increased by more than $5 billion per day. This is much more than the value of all the real estate owned by Trump. #Trump#cryptocurrency 👂More on Trump's Ear ⚠️

TONlines – News

@tonlines · Post #7324 · 22.05.2025 г., 11:25

⚡️TON Community: Join the Ultimate TON NFT Gathering in Lisbon #TON#cryptocurrency TON Community announces an exclusive one-day event, TON of People, in Lisbon on June 5, 2025. The event will feature key figures from the TON blockchain and cryptocurrency communities, providing insights into NFTs and blockchain marketing. Attendees will also have access to additional events during the NFC Summit. Source: link @tonlines

TONlines – News

@tonlines · Post #6753 · 14.04.2025 г., 12:08

⚡️xRocket News: Real-Time Crypto Rates and Referral System #Telegram#cryptocurrency xRocket News introduces a new @xrocket dash command in Telegram that provides instant cryptocurrency rates and changes within chats. Users can also benefit from a built-in referral system by typing @xrocket dash followed by desired tokens. The rates automatically update every 30 minutes in larger groups or channels. Source: link @tonlines

DWF Labs Broadcast

@Dwflabs · Post #167 · 20.01.2023 г., 07:40

BIT x DWF Labs Crypto Snapshot [13 Jan] 📰 Highlights: 🔸Shanghai Upgrade Well On Track With Latest Testnet Developments 🔸#Bitcoin Rebounds From Its Lows Back To $21,000 🔸Innovation And Sound Practices Are Key For #Cryptocurrency Integration Full read here.

TONlines – News

@tonlines · Post #7055 · 05.05.2025 г., 16:22

Trending Apps: Discover TonTradingBot for Seamless Crypto Management #Cryptocurrency#Web3 Trending Apps highlights TonTradingBot, a comprehensive solution for crypto enthusiasts to manage trading operations directly within the chat. It offers features such as sniper mode, limit orders, and copy-trading, along with tools like Fast Swap and Honeypot Detection, promising secure and fast performance. Source: link @tonlines

123•••10•••20•••30•••40•••4344
ПретходнаСтраница 1 од 44Следна