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

Пребарај: #fton

当前筛选 #fton清除筛选

The long-awaited listing of the token from Fanton Fantasy 🟨 We would like to remind you that #FTON is a utility token of the Fanton Fantasy project, necessary for playing in their tournaments. Token holders will be able to participate in betting and ⛏ farming, receive in-game bonuses, and also have the exclusive right to purchase NFT cards of the project. ↗️ The listing of $FTON will take place on October 1 at 13:00 UTC (16:00 Moscow time) on three CEX exchanges at once: Kucoin, Gate.io , MEXC. In our 🪙#TON network, the pool will appear at 13:15 UTC and unfortunately only on 1 DEX exchange – Ston.FI. At the same time, the team itself states that they are working with other sites on the token listing, so we are waiting for announcements. ➖After listing, life is just beginning, and we will begin to systematically increase the utility for $FTON, both for Fanton Fantasy players and ordinary cryptans! The team also reminded us that Notcoin and Tonstarter are among their key partners: ➖Over the past 1.5 years, we in the Fanton team have held many calls with the creators of the best platform for social campaigns — Community, as well as Notcoin, which blew up TON and Telegram in early 2024. ➖Since then, we have been calling the guys weekly, maintaining a connection on the topic of launchpads and launching ⚽️ $FTON, received expertise and connections, and are finally close to launching our utility token. Fanton | News | Chat | ChainGPT

Hashtags

TONlines – News

@tonlines · Post #6842 · 18.04.2025 г., 16:26

Fanton EN: New Legendary NFTs and Staking 2.0 #NFT#FTON Fanton EN presents the new Staking 2.0, featuring a convenient chart and distinguished Legendary NFTs, including players like Batrakov and Osipenko. The first round of NFT distributions for FTON stakeholders will start tomorrow. Participants can exchange injured NFTs through support. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #6849 · 18.04.2025 г., 23:12

⚡️Fanton EN: Launch of Staking 2.0 #Fanton#FTON#NFT Fanton EN channel has announced the launch of Staking 2.0 in the game, offering lucrative opportunities for players. By staking $FTON tokens, participants can earn rewards surpassing the token’s value and receive additional NFTs. Important deadline: Stake before April 19 to secure your NFT before the 25th RPL round. Source: link @tonlines

TONlines – News

@tonlines · Post #6841 · 18.04.2025 г., 16:01

⚡️Fanton EN: Launch of Staking 2.0 with NFTs and Tournaments #FANTON#NFT#FTON Fanton EN introduces Staking 2.0, featuring NFTs, tournaments, and appealing bonuses. Participants can stake FTON in four different pools, each offering unique rewards like NFT cards, tournament entry, and up to 10% APY. The update includes guaranteed RPL NFTs and the opportunity to join exclusive pools with limited slots. Source: link @tonlines

TONlines – News

@tonlines · Post #7022 · 02.05.2025 г., 08:51

⚡️Fanton EN: May Leaderboard Kicks Off with New Rewards #FTON#NFT#RPL Fanton EN has announced the results for April with $FTON and NFT card distributions to players. The May Leaderboard requires participants to earn at least 50 trophies to share a 1 million $FTON prize pool. Top players will also receive Rare RPL cards, selected based on rank. Source: link @tonlines

🏷 Start of presale from Fanton 🟡Placement will take place on August 7th at 11:00 UTC on the Magic Square platform 🟡Presale price – $0.023 (5% discount to the IDO price) 🟡Total raised amount – $150,000 🏆 We want to remind you that $FTON is a utility token for the Fanton Fantasy game, necessary for playing in project's tournaments. Token owners will be able to participate in staking and ⛏ farming, receive in-game bonuses, and also have exclusive right to purchase NFT cards of the project. The first part of FCFS/Whitelist Round: 🟨Create an account on Magic Square and go through KYC 🟨Use wallet which completed the Zealy campaign 🟨Click "Join Whitelist" Second part of the ProRata Round will begin on August 8th at 11:00 UTC. 📊 Allocation will depend on thr amount you contributed in relation to other participants. Trading with other users (until TGE) will appear on Magic Square OTC marketplace. More information in detailed guide - link here. #fanton#magicsquare#fton