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

Резултати

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

Пребарај: #imf

当前筛选 #imf清除筛选
Trump's Ear

@trumpsear_tg · Post #2371 · 15.04.2026 г., 13:58

A further escalation in the Iran war could trigger a global recession that would affect the UK more than any of the other G7 nations, the International Monetary Fund has warned. Against an increasingly volatile backdrop, the Washington-based fund said the economic damage from the Middle East conflict was steadily rising as it cut its growth forecasts for 2026 based on the impact of the war so far. #IMF#War 👂More on Trump's Ear ⚠️

Hashtags

经济信息联播

@eco_cn · Post #30614 · 15.04.2026 г., 02:36

#IMF 警告,中东冲突或将全球经济增速压至2%以下、逼近衰退门槛。#GDP 核心变量在于霍尔木兹海峡与能源供给: 冲击越久、破坏越深,通胀越易失控。 新兴市场受创最重,欧洲承压,美国相对韧性。通胀反弹令各国央行陷入增长与控价两难。

Hashtags

Venture Village Wall 🦄

@venturevillagewall · Post #3511 · 20.12.2024 г., 08:00

El Salvador Buys More Bitcoin El Salvador continues to accumulate Bitcoin despite an agreement with the IMF to reduce Bitcoin initiatives. The government now purchases 1 BTC daily, having bought 11 BTC today. As part of a $1.4 billion loan agreement with the IMF, the government will make Bitcoin adoption voluntary for the private sector, limiting government involvement. #ElSalvador#Bitcoin#IMF#Crypto#Funding

Venture Village Wall 🦄

@venturevillagewall · Post #4028 · 30.01.2025 г., 10:00

El Salvador Revises Bitcoin Strategy with IMF El Salvador amends Bitcoin law for IMF compliance, allowing voluntary crypto usage in private sector. In exchange for a $1.4B loan, Bitcoin adoption will be voluntary for private entities, limiting government participation. Read more here: forklog#ElSalvador#Bitcoin#IMF#Crypto#Finance #ElSalvador#Bitcoin#IMF#Crypto#Finance

वैश्विक स्तर पर चमकती भारतीय अर्थव्यवस्था।। सबसे तेजी से बढ़ती प्रमुख अर्थव्यवस्था के रूप में, भारत लगातार आगे बढ़ रहा है। आईएमएफ ने विकास अनुमान को 6.1% से बढ़ाकर प्रभावशाली 6.3% कर दिया है। #IMF#IndianEconomy#NewIndia

Venezuelanalysis

@venanalysis · Post #2352 · 29.04.2026 г., 18:45

🎥 VIDEO | Venezuela and the IMF: Short-Term Relief or Long-Term Pain? Venezuela has reestablished ties with the International Monetary Fund. But what comes next? After years of isolation, Caracas could gain access to roughly $5 billion in Special Drawing Rights, funds it hopes to use to stabilize essential services like electricity and water. In the short term, the move offers relief. In the long term, it raises deeper questions. Venezuela’s external debt is estimated at up to $170 billion, and any broader financial engagement could reopen the door to negotiations with creditors and potential IMF-backed programs. For a country with a long and contentious history with the Fund, the stakes are high: access to liquidity versus the risk of increased financial dependence. Is this a step toward recovery or the beginning of a new cycle of debt? #IMF#CentralBankofVenezuela#USVenezuelaRelations

Addis Standard

@addisstandardeng · Post #21104 · 17.01.2026 г., 08:32

News: #IMF approves $261 million disbursement to #Ethiopia, cites stronger macroeconomic performance The International Monetary Fund (IMF) has approved the immediate release of US$261 million to Ethiopia under its Extended Credit Facility (#ECF), following the completion of the fourth review of the country’s reform program. The decision, the Fund said, reflects “stronger-than-anticipated macroeconomic outcomes and overall performance broadly in line with program commitments.” In a statement issued on 16 January 2026, the IMF said the Executive Board’s decision under the 48-month ECF arrangement will support Ethiopia’s balance of payments and fiscal financing needs. The disbursement brings total funding released under the program to approximately US$2.183 billion (SDR 1.6 billion). To strengthen the foreign exchange market, the IMF introduced a new performance criterion setting a zero limit on foreign exchange intervention outside of auctions. Read more: https://addisstandard.com/?p=54630

👆आईएमएफ के अनुसार, भारत प्रमुख क्षेत्रों में सुधार द्वारा उत्कृष्ट है: •निरंतर बैंक ऋण वृद्धि •एनपीए में गिरावट •उन्नत श्रम बाज़ार •कार्यबल में महिलाओं की बढ़ती भागीदारी •स्वास्थ्य, शिक्षा, भूमि और कृषि सुधारों में प्रगति #IMF#IndiaEconomy #EconomicGrowth

👆2023 में भारत की G20 की अध्यक्षता ने वैश्विक स्तर पर बहुपक्षीय नीति की प्राथमिकताओं को आगे बढ़ाने में देश की महत्वपूर्ण भूमिका को प्रदर्शित किया है। हम 2023 में G20 की अध्यक्षता के दौरान भारत के सशक्त नेतृत्व की सराहना करते हैं- आईएमएफ #IMF#IndiaEconomy #EconomicGrowth

👆भारतीय अधिकारियों की उनकी व्यापक आर्थिक नीतियों और सुधारों के लिए सराहना की जानी चाहिए, क्योंकि वैश्विक स्तर पर लगातार आर्थिक प्रतिकूलताओं के बावजूद भी अर्थव्यवस्था को मजबूती, और वित्तीय स्थिरता मिली- आईएमएफ #IMF#IndiaEconomy #EconomicGrowth

123•••56
ПретходнаСтраница 1 од 6Следна