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

Пребарај: #settleton

当前筛选 #settleton清除筛选

🗿STON.fix SettleTON The SettleTON team, after six months of hard work, has successfully deployed a refarming contract on TON, powered by STONfi v2 technology! ❓What is SettleTON for? When farming in a liquidity pool, reinvesting earned tokens is often unprofitable, so SettleTON decided to take on this task: Each pool regularly reinvests rewards into the pool, no longer needing to manually claim rewards. This solution optimizes fees as all users' funds are reinvested jointly. 🔗Try SettleTON 💬 The STON.fiteamnoted: This collaboration is proof of what’s possible in TON when innovation meets execution. We’re proud to provide the infrastructure powering this DeFi breakthrough. #STONfi#TON#SettleTON

❤️SettleTON is a finalist of The Open League Hackathon 🔒SettleTON is a platform for passive investments in the #TON ecosystem. Managing your crypto portfolio will be available in one click by purchasing an index for tokens and providing the possibility of automatic reinvestment. The project was one of 24 finalists out of 963 hackathon projects from the TON Foundation for $2,000,000. It is already known that #SettleTON is guaranteed to take home $10,000 in prize money and $10,000 in Telegram Ads as a hackathon finalist. 🚀AIRDROP from 20% of SettleTON prize money The team announced an upcoming airdrop of 20% of the SettleTON prize money from the hackathon, in gratitude for the incredible activity and support of the community. #Airdrop will be issued to everyone who holds their NFT and has at least 1 index token. As soon as the team receives prize money from 🤑 TON Foundation awards will be sent to all qualified participants. The rules published here. How to get the airdrop? 1. Log in to the bot 2. Get your ref. link 3. Invite as many frens as you can 4. Get the NFT of the project 5. Buy any of the SettleTON indexes. 🏅 On July 21, the three finalists of the #DeFi track will be determined with prizes of $35,000, $25,000, $15,000 respectively. We wish the project team to win the hackathon!❤️

🪄Reward Points and AirdropfromSettleTON🎈 SettleTONsent out the airdrop to its early users, immediately after receiving the prize from the TON Foundation for winning the hackathon. The conditions for receiving were: owning a SettleTON Lounch Pass NFT and buying an index for any amount from 1 TON. The snapshot was made on this 24.08.2024 at 22:00 UTC. 🪙We got 10 $TON to the balance Auto-reinvest is now available to everyone, in addition to this, the project is launching the Reward Points system this week. 💎Holders will get access to the APY Calculator and a $7,000#airdrop. Replenish liquidity in the app, get bonuses for owning exclusive NFTs and invite referrals. The more activity — the more rewards! Details in this guide (RU). ➡️Start reinvesting in SettleTON 🗓Reward Points system launching this week! #HODL#SettleTON#index

SettleTon Opens Up Its Tools to the Public 📊 Now each of us can use financial instruments in the SettleTON bot absolutely free of charge, whereas previously it was necessary to have a special NFT (floor ~47 TON). 💰 In our last post, we already mentioned the $7,000 #airdrop for NFT holders. Today, the team provided more details: In the coming days🪙Ton Foundation will award the finalists of the TOL Hackathon. Within 24 hours of the awarding of the prizes, we will hold an airdrop of $7,000 for early holders of the SettleTON Privileged Access NFT collection. 🧮 The team also introduced a new tool – APY Calculator. We will be able to quickly calculate our profitability directly in the bot. But this function will first be available to early #NFT holders, and they will test it until September 10. 🔥 Towards the end of August #SettleTon will launch a RP (Rewards Points) system for supplying liquidity and release "something really cool". 🗓 We are waiting for a "tasty" airdrop, getting ready for RP farming and index investing - this strategy is especially suitable for beginners and inexperienced traders. #invest#index#TON#crypto#trading SettleTON | GitBook | Chat EN | X

SettleTON v2.0 Major Release, WEB3 Collaboration, and instructions how to get SBT 🔄 The "v2.0" trend continues — after the recent Ston.Fi v2.0 update, we have the SettleTON project next in line. Below, we'll look at what's been added and updated in the new version: ➖ Improved MID-Risk index: Critical errors were fixed, increasing protocol stability. New #MetaVault system, which optimizes asset storage and makes the reinvestment process more efficient. ➖ Improved reliability: All asset contracts (vaults) now use their own database and infrastructure😊#SettleTON, therefore the balance and quality of reinvestment increases. ➖ A new section has appeared in the bot, in which you can earn RewardPoints (RP) for completing missions from SettleTON and their partners. 🫡SettleTON x WEB3 partnership and increased farming rewards: Team #WEB3 gave a good boost to their pool, you can see and touch it in the bot , in the "Vaults" tab. Also, soon Ston.fi pools will appear in SettleTON (ST), in their post they described the advantages of ST compared to direct deposits through #DEX. 🙏#SBT Hunting, featuring SettleTON: The popular staking project #JVault has launched a campaign in connection with the resumption of The Open League. For simple actions in Quest Bot and DeFi projects — providing liquidity, staking, swaps, subscribing to a channel, we have the opportunity to get an exclusive SBT. Plus, for all these shenanigans, we get additional points and rise in the #OpenLeague ranking, and then 🍔#TON itself. SettleTON | GitBook | Chat EN | X

SettleTon and Portfel Collaboration 🔥SettleTon has recently partnered with #TorchFinance, this time by adding a new project to the list – #Portfel. 💼 Portfel's goal is to become the main application for tracking our assets: all tokens, staking on multiple #DEX, provided liquidity, rewards, and using all the necessary #DeFi applications. The team shared their immediate plans and roadmap: 🟡#NFTs and their valuation 🟡Support for multiple addresses 🟡Staking platforms - #Tonstakers and #jVault 🟡Vaults by Storm.tg 🟡Token swaps via the best Dex Aggregator 🟡Token details page 🪅DeFiLlama also included#SettleTon on their platform, adding transparency and value for users. SettleTON | GitBook | Chat EN | X