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

Резултати

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

Пребарај: #commissions

当前筛选 #commissions清除筛选
占位符

@placeholderpics · Post #59044 · 13.03.2026 г., 17:03

♈羽メェー|Twitch直播: 感謝觀眾委託畫OC! #Commissions https://twitter.com/Feather_OuO/status/2032445212405227526

Hashtags

Cerezo

@CerezoArt · Post #904 · 02.03.2026 г., 18:29

ICON #COMMISSIONS SALE !!!! 😆😆😆 Heyyyy ONLY 3 SLOTS left! 💖 PLEASE READ RULES FIRST!!! 👀 - Any species. Any gender 👍 - Any character allowed😄 - If you're interested please send a message to @Sartikk🦌 - Payment via PayPal only, I use Invoices! ❤️ - I'll be taking 3 (0/3) Slots😄 - The cost will be 30USD☺️ - SALE 4 Icons x 100USD🤩 - I Reserve the right to refuse😦 ~ PRODUCT ~ - The final image will be a fully colored and digital .PNG - Files sended will be a online and full version - The icon will be a bust with the head and part of the chest of the character

Hashtags

Sabertoof's Arts!

@artbysabertoofs · Post #451 · 15.12.2025 г., 20:14

Hi yall! I'm opening for a couple of these headshots for $40! They are finely sketched and flat colored. ^^ Payment through Paypal invoice! DM or reply to inquire about a spot! I'm raising some funds for medicine/gas money so if you want to help without getting a commission, feel free to boost here: https://bsky.app/profile/sabertoofs.bsky.social/post/3m7zf26aslk25 Looking to get these little headshots done roughly 1-2 weeks after accepted. ^^ #commissions

Hashtags

Sabertoof's Arts!

@artbysabertoofs · Post #421 · 07.12.2025 г., 10:57

Hi everyone! I'm offering small headshot/bust doodles like these for $20, and +$15 for color. c: I want to get these done over the weekend, so I'll be working on them and may only take a small handful at this time. ^^ I really need to save money and get some things (and maybe buy myself something for my birthday), so I want to try and do these on stream, too. :D If I get any bites, I'll stream them this morning. ^^ https://picarto.tv/SABERTOOFS <- where I'll be streaming them! If there's any interest - please DM me or respond! :D #commissions

Hashtags

Sabertoof's Arts!

@artbysabertoofs · Post #406 · 20.11.2025 г., 15:09

Good morning everyone!! ❤️ I've opened for one, single-character slot to help cover my move a bit more! I've included some examples here of the quality that I'm offering! Offering the slot for $160. Turnaround time will be long with this, but as always, I will try to get everything tended to as soon as I can. I will also note that I'm moving *this weekend*! I'll be taking this time to settle in to my new home and rehabilitate a little bit before resuming proper work times. If you are willing to be super patient, I'll be happy to work with you. ❤️ DM or reply to claim this. I will invoice on Paypal once details are settled. ^^ Thank you! #commissions

Hashtags

Sabertoof's Arts!

@artbysabertoofs · Post #298 · 23.01.2025 г., 05:56

Hey yall! I'm just posting this here as well! I'm doing icon commissions right now for $40! Turnaround time roughly about a month, all things considered. Here's some examples of the ones I have so far. If you're interested in one, please feel free to DM me here or on BlueSky @Sabertoofs! #commissions Thank you for looking! ^^

Hashtags

Sabertoof's Arts!

@artbysabertoofs · Post #246 · 27.09.2024 г., 19:24

I'm open for one of these types of slots right now for $50! I went to run errands today and just barely had enough for my things, so I'd just like to open for another of these so I feel comfortable for the rest of the month. Please feel free to DM either on here or on X/Bsky @ Sabertoofs to claim. This will be done early October. P.S. I feel bad for opening for a Thing or two but haven't had much options to raise funds otherwise. I apologize. ;n; #commissions

Hashtags

Sabertoof's Arts!

@artbysabertoofs · Post #113 · 01.11.2023 г., 12:07

Hi, everyone! I've got some sketch #commissions open for about a week or so; please check the tweet if interested! https://twitter.com/sabertoofs/status/1719678166103392685 If you can't get one, a retweet helps a bunch. I'll have nothing for groceries/medications by Monday, so anything helps really. 😭

Hashtags

占位符

@placeholderpics · Post #59642 · 22.04.2026 г., 19:10

えむ: skeb納品です。リクエストいただきありがとうございました!!🌕🥛 #Skeb#commissions https://twitter.com/mu_005555/status/2046887037354324263

🎧Are looking for a ❗️Music Track❗️ that represents your Character, Fursona or YouTube, twich?🎹 ❕for a price of 50 dollars depending on the genre and time ✅ •🔥this is the place!🔥I can make a musical track with the personality of your fursona, even for 🔴YouTube🔴 or 🟣twich🟣 •The genre you want, without limits 🎸 🟢Only Paypal🟢 Dm ➡️@rocketwolfy #commissions#furryart#nsfw#sfw

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