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

Резултати

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

Пребарај: #virtualassets

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

@CryptoM · Post #64785 · 09.04.2026 г., 23:37

🚀 South Korea Implements New Rules for Managing Public-Sector Virtual Assets South Korea has approved a plan to manage 78 billion won, equivalent to approximately $57.7 million, in public-sector virtual assets. According to NS3.AI, the new regulations mandate that any seized or confiscated cryptocurrency from personal wallets must be promptly transferred to an institutional cold wallet, which is not connected to the internet. Additionally, the rules stipulate that private keys and recovery phrases must be controlled by at least two individuals through a split-access arrangement. #SouthKorea#PublicSector#VirtualAssets#Cryptocurrency#Regulations#DigitalAssets#CryptoSecurity#ColdWallet#Blockchain#CryptoPolicy

Crypto M - Crypto News

@CryptoM · Post #65410 · 13.04.2026 г., 05:53

🚀 South Korea Warns of Crypto Market Abuse via APIs South Korea's Financial Supervisory Service has issued a warning to consumers regarding increasing abuse in the cryptocurrency market linked to APIs. According to NS3.AI, these application programming interfaces are responsible for approximately 30% of the nation's virtual asset trading volume. The regulator highlighted that automated trading programs are being utilized to artificially inflate transactions and manipulate market conditions. In response, a consumer advisory was released, providing examples of such misconduct to raise awareness among investors. #SouthKorea#Crypto#Cryptocurrency#API#MarketAbuse#Regulation#ConsumerProtection#AutomatedTrading#VirtualAssets#InvestorAwareness

Venture Village Wall 🦄

@venturevillagewall · Post #4192 · 19.02.2025 г., 16:00

Hong Kong Targets Global Virtual Asset Hub Hong Kong unveils new roadmap to become a global virtual asset center, focusing on staking services, attracting liquidity, and exploring derivatives trading. Further endeavors include OTC and custody licensing. For details, visit Wu Blockchain News. #HongKong#VirtualAssets#Crypto#DeFi#Liquidity#Licensing#Staking#Derivatives#OTC#Custody#Regulation#Finance#Investment#Blockchain#Web3#MarketTrends#TechUpdates#Innovation#GlobalMarkets#FutureOfFinance

Crypto M - Crypto News

@CryptoM · Post #64584 · 09.04.2026 г., 09:15

🚀 Dubai's VARA Issues Guidance on Virtual Asset Issuance Dubai's Virtual Assets Regulatory Authority (VARA) has released guidance detailing the structuring, disclosure, and distribution of virtual assets, including stablecoins and real-world asset tokens. According to NS3.AI, the document outlines three issuance pathways, specifying that Category 2 issuances must be distributed through intermediaries licensed by VARA. This guidance serves to interpret VARA's existing issuance rulebook rather than establish new laws. Ruben Bombardi, general counsel at VARA, stated that the framework aims to provide issuers with enhanced regulatory clarity and assist users in making more informed decisions. #Dubai#VARA#VirtualAssets#Stablecoins#RealWorldAssetTokens#RegulatoryGuidance#IssuancePathways#CryptoRegulation#Blockchain#DigitalAssets

Crypto M - Crypto News

@CryptoM · Post #64567 · 09.04.2026 г., 08:32

🚀 South Korea's Unclear Tax Standards for Crypto Income Raise Concerns South Korea's National Tax Service has yet to establish definitive tax guidelines for decentralized finance (DeFi), staking, lending, and other forms of cryptocurrency income ahead of the new virtual asset tax regime set to begin next January. According to NS3.AI, the agency, in a written response to lawmaker Song Eon-seog, indicated that it is currently gathering international legislative examples and expert opinions to inform its approach. The lack of clarity on taxing profits from overseas exchanges outside the 56 jurisdictions covered by the Crypto-Asset Reporting Framework could lead to issues of fairness and potential capital flight. #SouthKorea#CryptoTax#DeFi#Staking#Lending#VirtualAssets#TaxRegime#NationalTaxService#CapitalFlight#InternationalLegislation

Crypto M - Crypto News

@CryptoM · Post #65128 · 11.04.2026 г., 07:24

🚀 South Korea Considers Seizing Principal in Virtual Asset Insider Trading Cases South Korea's financial regulators are contemplating the inclusion of a clause to seize the principal in virtual asset insider trading cases in the upcoming second phase of legislation expected later this year. According to PANews, under the current Virtual Asset User Protection Act, the government can only confiscate investment principal in cases of fraudulent transactions or market manipulation. There is no legal basis for seizing the principal in insider trading cases. The Financial Supervisory Service has recently submitted this issue to the Financial Services Commission, which is currently reviewing whether to incorporate it into the second phase of the law. In the stock market, all improper trading crimes can result in the confiscation of the investment principal. #SouthKorea#VirtualAssets#InsiderTrading#FinancialRegulation#Legislation#InvestmentPrincipal#FinancialSupervisoryService#FinancialServicesCommission#MarketManipulation#UserProtection#StockMarket

Crypto M - Crypto News

@CryptoM · Post #65218 · 12.04.2026 г., 04:04

🚀 Argentina Revises Investor Qualification Rules to Include Virtual Assets Argentina's National Securities Commission (CNV) has issued Resolution No. 1125/2026, revising the definition of qualified investors to include virtual assets. According to Foresight News, the new regulation allows individuals or entities to combine virtual assets with securities investments and bank deposits to meet the threshold of 350,000 UVA (Argentinian inflation-linked units) for qualification. The revision also introduces provisions related to crowdfunding, permitting non-qualified investors to participate in specific public offerings. The investment limit for a single transaction is set at 3,000 UVA, with a cumulative cap of 10,000 UVA, and must not exceed 5% of the investor's personal assets per transaction or 10% cumulatively. #Argentina#virtualassets#qualifiedinvestors#investmentregulations#crowdfunding#publicofferings#securitiesinvestments#bankdeposits#UVA#financialregulation#investmentrules