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

Резултати

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

Пребарај: #xbanking

当前筛选 #xbanking清除筛选

👍XBanking full update: fast unstake, security and the highest APR! What is XBanking? One of the largest DeFi pool aggregators (17,000+ pools, 46 networks, 150+ tokens), with increased interest rates for placing various tokens. The project has been audited and has a valid certificate from Certik🛡 🤩Advantages of the platform We know that in crypto it is not only profitability that is important, but also mobility.#XBanking offers🔓fast unstake — you don't have to wait for the validation cycle to end, which can last up to 36 hours: withdrawal from staking is available at any time! 🪧Maximum profitability For example, the APRin the liquidity pool is🤑$TON is 22%, and liquid staking tokens tsTON, stTON can be repledged at another 8%. There is no such yield on any of the TON platforms! For comparison, TON staking APR: 💎 MyTonWallet — 3.91% Classic Staking 🪙 Tonkeeper — 3.89% Liquid Staking 🕊 StormTrade — 15.97% vault for DEX trading 📊Interest on TON tokens on 👍XBanking: 🤑$USDT— 32% APR 🐕‍🦺$DOGS — 28% APR 🐾$CATI — 18% APR Higher APRs are usually associated with higher risks, so such instruments require a conscious approach, understanding of the mechanics and proper risk management. 🔥The platform has been updated — a cool, intuitive interface, everything is convenient and clear. Working with the platform has become even easier. There are even more opportunities ahead: farming in the TON network is coming very soon 👍Explore all liquidity pools Website | Channel | Chat | X | Medium

Hashtags

👍One Token Instead of Two & No Impermanent Loss – how XBANKING is Redefining DeFi Standards? Liquidity pools are one of the best ways to earn passive income in DeFi. However, the traditional model comes with two major drawbacks: 👎Traditional pools require two tokens to be deposited in equal proportions. 👎Impermanent Loss – losses caused by price fluctuations of one asset in the pool. 👍#XBANKING eliminates these barriers! 👍 Now you can deposit just one token and earn rewards on the full amount, while the system automatically balances the pools, mitigating impermanent loss. 📈How Does XBANKING Ensure High Returns? • Trading fees – liquidity providers earn a share of commissions from #DEX using these pools. • Automated pool management – smart allocation of liquidity optimizes returns. • Farming & staking – additional rewards for participating in selected pools. ✅How Does XBANKING Reduce Risks? • Algorithmic pool balancing – smart contracts automatically maintain liquidity ratios. • Liquidity insurance fund – protects liquidity providers from unexpected losses. • Smart contract audits – security is ensured through independent auditing firms. #DeFi is evolving – only those who adapt and use the most effective tools stay ahead. Are you? ⚡️Unlock the Full Potential of DeFi Website | Research | Guides | App | X

👍XBANKING has launched a referral program! Here’s how it works: 👍 Earn 10% of the income generated by users you invite 👍 Commissions are based on the profit your referrals earn from liquidity pools 👍 Fully transparent: the higher the TVL of your referrals, the more you earn Getting started is easy: ⚫️Create your personal referral link ⚫️ Share it — via social media, your blog, or communities ⚫️ Earn together with those who join through your link 🪙 Passive income isn’t always about capital — sometimes it’s simply about sharing the right tools. #DeFi#XBANKING#Web3#Crypto

👍XBANKING celebrates 2 years – join in and earn bonuses! ❓ There are no magic "earn" buttons in crypto, but there are tools that, when approached wisely, allow you to generate passive income. Some of these tools offer higher rewards, but also come with higher risks. These require understanding. One such tool is liquidity pools. Today’s spotlight is on #XBANKING, one of the largest DeFi liquidity aggregators (17000+ pools, 46 networks, 150+ tokens), now offering boosted APY for staking TON and other tokens: 💧 TON — 22% APY 💧 DUREV — 11% APY 💧 DOGS — 28% APY 💧 NOT — 14% APY 💵Why is this beneficial for holders? By providing tokens to liquidity pools, you can earn higher yields than traditional staking. This strategy requires an understanding of how it works, but when approached strategically, it allows for efficient asset management while maintaining a relatively high level of security. The project has successfully passed security audit from #Certik🛡 ⏱ These increased rates are available until the end of June 2025. 👍You can deposit $TON and other assets at mini-app:app.xbanking.org Website | Channel | Chat | X | Help #NFR#DYOR#DeFi#farming

USDE by 👍XBANKING — A Next-Generation Decentralized Stablecoin XBANKING has launched USDE, a new stablecoin built specifically for DeFi, trading, and everyday payments. USDE blends stability, decentralization, and yield — offering 8% APR just for holding. Built on the 🤑 Solana blockchain. 💰USDE minting is now live ➡️app.xbanking.org 👍 1 USDE = 1 USD — always. It’s backed 1:1 by liquid assets — USDT and USDC, with real-time reserves exceeding 101%. 🔎Why hold USDE? ✔️ Earn 8% APR simply by holding — the yield is built into the token. ✔️ No need to chase DeFi protocols or calculate risks — USDE starts earning immediately. ✔️ Use it like any other stablecoin: trade, add to liquidity pools, lend, or borrow. ✔️ 100%+ backed by USDT and USDC — no liquidation risks like with collateralized stablecoins. ✔️ Runs on Solana — fast, cheap, and user-friendly. 😀How does it work? • Users deposit USDT or USDC into the XBANKING smart contract • In return, they receive USDE at a 1:1 ratio • The deposited stablecoins are allocated to DeFi strategies (liquidity pools, farming, etc.) • The yield is distributed among all USDE holders 💼What you can do with USDE ✔️ Hold to earn 8% APR ✔️ Swap to USDT or USDC with zero fees ✔️ Trade on DEXs (available on Raydium) ✔️ Provide liquidity ✔️ Lend and borrow 🛡 What makes USDE stand out? • Backed only by $USDT and $USDC • Reserves exceed 100% • 8% APR just for holding • Minting and burning are controlled via smart contracts • No liquidation mechanisms — unlike collateralized stablecoins • Includes a token freeze function as an additional safeguard against phishing or exploits 📌Where to use USDE — Mint: app.xbanking.org — Smart contract: 8dt9fQhoRKuWCSAsYweG2UMF3rbcG9xzNCTWXXSmdmEi — View on Solscan — DEX: Raydium USDE by XBANKING — a hybrid stablecoin designed for active DeFi use and long-term yield. #USDE#Xbanking#Stablecoin#DeFi#Solana#Raydium#CryptoUX

Watch the video, like it 👍 and comment 💬 to get a prize! 🎞youtube.com/XBANKING 🎞youtube.com/XBANKING 🎞youtube.com/XBANKING 💵 The author of the best comment will get $10 from our channel! Don't forget to subscribe to our YouTube channel! #DeFi#Crypto#PassiveIncome#YieldFarming#LiquidityPools#Web3#XBANKING#CryptoInvesting