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

Резултати

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

Пребарај: #securities

当前筛选 #securities清除筛选
UzCSD | Markaziy depozitariy

@uzcsd · Post #2812 · 09.11.2022 г., 05:04

New issue of Uzbekistan Central Securities Depository’s monthly newsletter “depo-REPORTER” covering key depository news of Octember 2022. Download depo-REPORTER No 14 (PDF, 1.4 Mb) #depo#reporter#news#central#depository#securities#issues deponet.uz|Tg|Fb|Inst|Youtube

UzCSD | Markaziy depozitariy

@uzcsd · Post #2751 · 10.10.2022 г., 12:31

New issue of Uzbekistan Central Securities Depository’s monthly newsletter “depo-REPORTER” covering key depository news of September 2022. Download depo-REPORTER No 13 (PDF, 0.8 Mb) #depo#reporter#news#central#depository#securities#issues deponet.uz|Tg|Fb|Inst|Youtube

UzCSD | Markaziy depozitariy

@uzcsd · Post #2696 · 12.09.2022 г., 05:03

New issue of Uzbekistan Central Securities Depository’s monthly newsletter “depo-REPORTER” covering key depository news of August 2022. Download depo-REPORTER No 12 (PDF, 0.8 Mb) #depo#reporter#news#central#depository#securities#issues www.deponet.uz|Tg|Fb|Inst|Youtube

Venture Village Wall 🦄

@venturevillagewall · Post #4262 · 27.02.2025 г., 19:00

BitMEX Seeks Buyer with Investment Bank Help BitMEX, a prominent cryptocurrency exchange, is actively looking for a buyer and has engaged Broadhaven Capital Partners for assistance. Founded in 2014 by Arthur Hayes, BitMEX faced legal challenges in the U.S. concerning anti-money laundering protocols, leading to Hayes' resignation as CEO. For more details, read here. #BitMEX#Crypto#VC#Blockchain#Exchange#Investment#FinTech#AML#Securities#Trading#Cryptocurrency

Venture Village Wall 🦄

@venturevillagewall · Post #4316 · 05.03.2025 г., 22:00

U.S. Releases Seized Crypto Mining Machines U.S. authorities begin releasing seized Chinese-made cryptocurrency mining machines, totaling up to 10,000 units at various ports. Synteq Digital's CEO notes resistance from some CBP officials towards Bitcoin mining, hindering the industry's growth. 🔗Read more In related news, BioNexus Gene Lab approves Ethereum as its treasury asset; Bitcoin open interest reaches lowest since August; and Bitwise files for Aptos ETF. 🔗BioNexus News 🔗Bitcoin Open Interest 🔗Bitwise Filing #Crypto#Bitcoin#Ethereum#Mining#BioNexus#Aptos#ETF#VC#Blockchain#Finance#Investment#DeFi#Securities#Regulation#Innovation#MarketTrends#OpenInterest#USeconomy

Venture Village Wall 🦄

@venturevillagewall · Post #4162 · 15.02.2025 г., 19:00

Milei Withdraws LIBRA Support Amid Cash Out Argentinian President Javier Milei retracts his endorsement of $LIBRA after insiders reportedly cashed out $107 million. The move raises questions about transparency and the impact on the cryptocurrency's reputation. For more details, visit The Block. #Argentina#Milei#LIBRA#Crypto#DeFi#Blockchain#Investment#Transparency#Finance#Market#News#Updates#Economy#InsiderTrading#Regulation#Securities#Volatility#Trends#DigitalCurrency#Cryptocurrency

Venture Village Wall 🦄

@venturevillagewall · Post #4072 · 05.02.2025 г., 10:00

Major Updates on Bitcoin and Ethereum 🔗 *Roman Storm secures legal funding for trial* with support from Paradigm and Vitalik Buterin! Details here: Leviathan News. 🔗 David Sacks confirmed evaluating a *national Bitcoin reserve* is a priority for Trump's Digital Assets Task Force. BTC is touted a *superior store of value*. Regulations on crypto incoming within six months! 🔗 XRP Ledger briefly halted due to validation issues but self-healed. More info: Coindesk. 🔗 Hong Kong weighs *Bitcoin as a strategic reserve*, urging to accelerate feasibility studies. Insights here: Wu Blockchain News. 🔗 Ethereum's *supply rises* back to pre-merge levels due to Dencun upgrade, signaling inflation. More: The Block. 🔗 U.S. to consider Bitcoin reserve as an essential economic security asset; institutional adoption underway! #Bitcoin#BTC#Ethereum#ETH#Crypto#Legal#Funding#XRP#Regulations#HongKong#StrategicReserve#DigitalAssets#AI#VC#MicroStrategy#Inflation#Securities#DeFi#Stocks#Bonds#ETFs

Venture Village Wall 🦄

@venturevillagewall · Post #4035 · 31.01.2025 г., 04:00

Tokenized Mining Notes Coming to El Salvador Bitfinex Securities to launch Blockstream Mining Note 2 (BMN2) in Q1 2025. BMN2 offers returns based on bitcoin mined by Blockstream. Previous note (BMN1) delivered over 1,212 BTC to investors in three years. More details in the article here: Read more #Bitfinex#Blockstream#BMN2#ElSalvador#Bitcoin#Crypto#Investment#Tokenization#Mining#BTC#Finance#DeFi#DigitalAssets#Securities#Blockchain#Trading#Market#Returns#BMN1#Innovation#Economy

Venture Village Wall 🦄

@venturevillagewall · Post #4007 · 28.01.2025 г., 10:00

Metaplanet Plans $745M Bitcoin Purchase Tokyo-listed Metaplanet aims to raise ¥116 billion (approx. $745M) through 21 million share subscriptions at 0% discount for Bitcoin acquisitions. This represents one of the largest financing plans for Bitcoin by any Asian publicly traded company. Detailed info available here: link. Meanwhile, U.S. Bitcoin and Ethereum ETFs received $1.9B in inflows during Trump's first week, bringing total digital asset inflows for 2025 to $4.8B. U.S. Senate also confirmed pro-crypto Scott Bessent as Treasury Secretary, expected to influence crypto regulations amid heightened interest. #Bitcoin#ETF#Crypto#Investment#Metaplanet#Asia#Treasury#DigitalAssets#BTC#ETH#Finance#NASDAQ#WallStreet#MarketTrends#Inflows#Securities#Cryptocurrency#USeconomy#Regulations#Trump#ProCrypto

Venture Village Wall 🦄

@venturevillagewall · Post #4168 · 16.02.2025 г., 19:00

Argentina's Opposition Eyes Impeachment Over LIBRA Argentina's opposition is considering impeachment for President Milei after conflicting support for the LIBRA token. This follows a controversial launch that saw rapid investment and then a significant drop in value, leading to accusations of mismanagement and deception. The situation raises questions about political influence in cryptocurrency projects. Read more: Reuters #Argentina#LIBRA#Crypto#Impeachment#Milei#Investment#MarketManipulation#EconomicCrisis#Blockchain#DeFi#RugPull#Politics#Cryptocurrency#TokenLaunch#InsiderTrading#Securities#AI#VC

Venture Village Wall 🦄

@venturevillagewall · Post #3889 · 16.01.2025 г., 04:00

Thai SEC Considers Bitcoin ETF Approval The Thai Securities and Exchange Commission is evaluating a proposal to approve a Bitcoin ETF for listing on its local exchange. Currently, Thai investors can only access overseas Bitcoin ETFs through a fund of funds product launched in mid-2024. Read more #Thailand#Bitcoin#ETF#Crypto#Investing#Finance#USDC#fxUSD#XRP#WhaleAlert#Assets#Trading#Decentralized#Yield#Securities#Exchange#LocalMarket#DigitalAssets#BlueChip#Stablecoin#VC

Venture Village Wall 🦄

@venturevillagewall · Post #4328 · 07.03.2025 г., 07:00

Trump Establishes Strategic Bitcoin Reserve Former President Trump has signed an order to create a strategic Bitcoin reserve in the U.S., based on approximately 200,000 BTC confiscated by the government. This reserve will serve as a savings asset, not intended for sale, acting as a digital Fort Knox. Meanwhile, analysts indicate that governments may follow the U.S. lead, reducing the likelihood of Bitcoin bans from regulators. Post-announcement, Bitcoin saw a price drop from $91,000 to $85,000 but has since recovered to $88,000. No altcoins are currently included in the reserve plans. Full details here: Reuters #Bitcoin#crypto#Trumpr#US#Blockchain#Finance#Regulation#Assets#DigitalCurrency#Investments#Savings#Market#Trading#Reserves#Government#FTX#Securities#FortKnox#Economy#PriceDrop#StrategicReserve

12
ПретходнаСтраница 1 од 2Следна