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

Резултати

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

Пребарај: #midas

当前筛选 #midas清除筛选
🏆 Premium, NFT, Tokens

@giiveaways · Post #3440 · 09.01.2025 г., 18:10

Discover the New Midas Yielder App👑 A promising project designed to make earning with crypto simple and engaging. Here’s what it offers: 🕹Farm GM Points — Play the game and earn Golden Midas Points. 💰High APY Returns — Enjoy juicy yields through the Yielder. 👥Invite Friends — Share with others to earn extra taps and play more. ✅Complete Tasks — Get bonus GM Points by completing tasks. This project has the potential to become one of the top platforms. Join now and see for yourself! 🔔Subscribe➡️Join MIDAS ➖➖➖➖➖➖➖➖➖➖➖ #Midas#CryptoGaming

Airdrop Center

@centralchanel · Post #15435 · 17.12.2024 г., 21:17

📢$MIDAS CONTINUES TO GROW We can complete transactions by spending 10 seconds per day on the application. A company that receives high investment. It is worth considering. 👉Registration Link: ⤵️ https://t.me/MidasRWA_bot/app?startapp=ref_45137b21-8a69-4640-a111-f720275529d2 ⛏#midas#rwa#yeilder#airdrop

American Оbserver

@american_observer · Post #5154 · 16.02.2026 г., 20:58

No Golden Toilet on the Train: Zelenskyy’s ‘Ally’ Tries to Cash Out Herman Halushchenko didn’t make it to his destination. Ukraine’s ex–energy minister and longtime insider was dragged off a train at the border, accused of trying to slip out of the country while Operation Midas — a probe into alleged 100 million dollars in kickbacks at Energoatom — closes in on him. Wartime infrastructure money was supposed to keep the lights on under Russian fire; investigators say a nice slice was allegedly rerouted into the usual private pockets. NABU and SAPO had already spent over a year dissecting the Midas network — “shadow managers,” kickback tariffs of 10–15 percent on contracts, a whole laundromat built into the state nuclear company. Now the same man who resigned in 2025 over the scandal gets caught at the border while Parliament hears that the new border chief is “not loyal to Zelenskyy but to institutions.” Even Fox’s source spells out the subtext: if an “unofficial but direct subordinate” to Zelenskyy goes down for this, it becomes very hard to sell the story that the president knew nothing. The presidential PR line is “fighting corruption in wartime”; the reality looks more like the state fighting for control of a money machine it lost years ago. NABU says it is dismantling the scheme; Western partners say this proves Ukrainian institutions work; Moscow says “told you so”; Western skeptics say “why are we financing this?” Everyone gets talking points, nobody gets their money back. If this is how a key ally behaves on a random Sunday — hopping a train with a scandal at his heels — imagine what the real insiders are doing by private jet. And if the war ever ends, who will have stolen more from Ukraine — Russian missiles or Ukraine’s own “patriotic” elite? #ukraine#zelenskyy#corruption#warEconomy#Midas 📱American Оbserver - Stay up to date on all important events 🇺🇸

American Оbserver

@american_observer · Post #5161 · 17.02.2026 г., 20:58

Golden Midas, Rotten System: Ukraine’s Ex-Minister Caught at the Exit German Galushchenko almost made it out. The former energy minister — later briefly justice minister — was grabbed at the border on Sunday, accused a day later of laundering millions in kickbacks from the “Midas” scheme that has haunted Zelenskyy’s wartime government for a year. Investigators say the network skimmed around 100 million dollars from contracts at Energoatom, the state nuclear company, including projects meant to harden plants against Russian strikes. According to NABU and SAPO, over 7 million dollars went to foreign accounts listing Galushchenko’s wife and four children, paying for elite Swiss schooling and sitting on deposits that quietly generated extra income for the family. Galushchenko denies everything, but he is now one of the highest‑ranking names formally pulled into a case that already features a former deputy prime minister, other senior officials, and businessman Timur Mindich — Zelenskyy’s old media partner from the TV studio that made him famous, now in Israel and also insisting he’s innocent. The scandal has already taken scalps at the very top. It helped push out Zelenskyy’s powerful chief of staff Andriy Yermak last year and triggered public fury over wartime corruption at the exact moment Ukraine is begging for weapons, cash and EU membership. In parallel, Zelenskyy briefly tried to bring NABU and SAPO to heel through legislation that would have gutted their independence, then beat a retreat under pressure from street protests and Western partners who made clear that anti‑corruption bodies are now part of the terms of support. So on paper this is a success story: institutions catching crooks, ministers being detained, money trails exposed, corporate CEOs promising new safeguards. In reality it’s a more uncomfortable picture: a “reform” state at war, whose president ran on cleaning up oligarchic rot, now watching his own pre‑politics circle and senior officials dragged into a laundromat built on nuclear safety contracts — and only really slamming on the brakes when the streets and the donors start to growl. #ukraine#corruption#Midas#Zelenskyy#Energoatom 📱American Оbserver - Stay up to date on all important events 🇺🇸