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

Пребарај: #usdebt

当前筛选 #usdebt清除筛选
Crypto M - Crypto News

@CryptoM · Post #64964 · 10.04.2026 г., 12:30

🚀 Jamie Dimon Warns of Rising U.S. Debt Risks and Global Deficits Jamie Dimon has expressed concerns over the increasing risks associated with U.S. debt. According to NS3.AI, Dimon referenced a Congressional Budget Office forecast predicting that the debt-to-GDP ratio will escalate from the current 100% to 120% by 2036. He highlighted that global deficits are currently at 5%, despite the relatively healthy state of the global economy. Dimon also cautioned that a future downturn in the credit cycle could lead to higher-than-anticipated losses in leveraged lending. #USDebt#GlobalDeficits#DebtToGDP#CreditRisk#LeveragedLending#EconomicForecast

Crypto M - Crypto News

@CryptoM · Post #65332 · 12.04.2026 г., 23:51

🚀 Global Currency Order Restructuring May Lead to Long-Term Dollar Depreciation According to Jin10, a report by China International Capital Corporation (CICC) suggests that after the short-term factors boosting the dollar fade, the narrative of global currency order restructuring and the weakening of dollar hegemony may once again dominate market direction. The United States' continuous accumulation of net external debt increases its need for dollar depreciation. The uncertainty surrounding U.S. President Donald Trump's policies and the unresolved risks of dollar 'weaponization' also dampen market demand for U.S. assets. The new Federal Reserve Chair, Walsh, advocates for a 'balance sheet reduction' policy, which could objectively help restore the dollar's credibility if implemented. However, Walsh's policy is constrained by the resilience of the real economy and financial markets, as well as political limitations. Additionally, Trump's foreign, trade, and economic policies continue to negatively impact the dollar's credibility. Considering the overall impact of Walsh and Trump's policies, it is difficult to conclude that the dollar's credibility will improve in the future. We anticipate that the global currency order may continue to restructure, driving the dollar to maintain a long-term depreciation trend. #GlobalCurrencyOrder#DollarDepreciation#USDebt#DollarHegemony#FederalReserve#MonetaryPolicy#TrumpPolicies#CICCReport#FinancialMarkets#CurrencyRestructuring

Crypto M - Crypto News

@CryptoM · Post #65191 · 11.04.2026 г., 18:19

🚀 U.S. Public Debt Increases by $571.28 Billion, Reaching $38.969 Trillion The United States public debt has increased by approximately $571.28 billion this year, reaching a total of $38.969 trillion as of April 7, 2026. According to NS3.AI, this figure encompasses both debt held by the public and intragovernmental holdings. In an interview with NPR, JPMorgan Chase CEO Jamie Dimon expressed concerns that the growing debt burden could pose challenges, potentially leading to higher market rates and reduced demand for U.S. Treasurys. #USDebt#PublicDebt#USFinance#GovernmentDebt#EconomicNews#USMarkets#Treasury#DebtCrisis#JPMorgan#Macroeconomics

IELTS|Newspapers & Magazines|English

@emagzinewspars · Post #9341 · 15.10.2025 г., 01:52

#The_Barron's 🇺🇸📕[PDF]⬇️ 13 #October2025 #Weekly_Magazines For learning, for free(dom). @backupofmagazines In this issue, Oracle founder #LarryEllison takes center stage, betting big on #AIInvestment in what may be his boldest move yet. The issue unpacks market jitters over a tech-driven bull run, rising #Gold and #USDebt, and the resilience of #ESG investing. Insights span #Ferrari’s EV gamble, #ImmigrationEconomics, and potential Fed leadership shifts. For savvy investors, Barron’s explores where the smart money is heading—plus, a special “Guide to Wealth” offers survival strategies for volatility. #Oracle#StockMarket#EllisonUnbound#TechBubble#Barrons#RetirementPlanning