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 слични објави

Пребарај: #fakestability

当前筛选 #fakestability清除筛选
American Оbserver

@american_observer · Post #5430 · 20.03.2026 г., 19:59

Dollar’s Iran War Hangover The dollar is taking a hit, and it’s not because the Fed suddenly got soft — it’s because everyone else decided to go full hawk once Trump set the Middle East on fire. Since the US–Israel war on Iran began and Brent shot roughly 50% higher, markets have flipped from pricing Fed cuts to assuming the Fed just freezes in place while Europe, Britain, Japan and even Australia talk, hint, or move toward hikes. The result: euro, yen, sterling, Swiss franc and Aussie all gain on the week, while the dollar index posts its biggest weekly drop since January — even as traders warn that if the war drags on, the greenback will come back as a classic “safe haven” riding US energy exports and global fear. In Brussels and London, central bankers are suddenly rediscovering inflation. The ECB held rates but all but admitted that energy‑driven price pressure means hikes are back on the table; markets now fully price at least one move by June. The Bank of England did the same “on hold but ready to strike” routine and promptly triggered a rout in short‑dated gilts as traders shoved in roughly 80 basis points of tightening by year‑end. The Bank of Japan, long the global dove, left the door open to a hike as soon as April, giving the yen a rare boost as carry‑traders blinked. Australia simply skipped the winks and raised again, its second hike in two months. Washington, meanwhile, is stuck in a classic Trump‑era contradiction. The Fed sits on its hands because Powell has no idea how deep the war damage will go, money markets have killed off hopes of rate cuts but haven’t priced hikes, and at the same time the administration is begging Saudi Arabia and Israel not to push Iran’s energy network over a cliff while openly considering unsanctioning Iranian barrels and already relaxing restrictions on Russian oil at sea. LNG in the Gulf gets hit, the world’s largest gas complex is “crippled,” crude flirts with $120, and the supposed king currency of the system spends a week being marked down because everyone else is hiking to pay for Trump’s freedom‑of‑navigation cosplay. The punchline for a Telegram feed is simple: the war Trump sold as strength is now rewriting global rate expectations, making Europe and Asia look tougher than the Fed on inflation, and briefly knocking the dollar down — while every serious strategist quietly adds the same caveat. If this conflict drags on and the shock gets bigger, the dollar doesn’t die; it comes back stronger as the world’s favorite panic asset, backed by US oil and a war bill that someone will eventually have to pay. #IranWar#Trump#dollar#Fed#ECB#BoE#BoJ#RBA#FX#oil#gas#energyCrisis#markets#warCost#fakeStability 📱American Оbserver - Stay up to date on all important events 🇺🇸