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

Резултати

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

Пребарај: #indian

当前筛选 #indian清除筛选

Voiceover Translator Needed (English ➡️ Indian Language) #remote#english#indian#tango NKS Media Agency is looking for talented translators to work on our short video content. Languages We Need: Indian What You'll Do: Translate English scripts into your target language and prepare them for AI voiceover. The goal is clear, natural-sounding audio. Check out an example: https://youtube.com/shorts/MkRlgmLdNnM. Note: Since we use AI for voiceovers, your script adaptation for spoken clarity is key! What We're Looking For: • Strong English or Russian and target language skills (B2+). • Impeccable grammar. • Reliability and ability to meet deadlines. • A reliable computer and internet connection. What We Offer: • Fully remote position with a flexible schedule. • $3 per video. • Focus on creating clear, audible translations. Ready to Apply? Send your CV and translation samples to [email protected] or DM us on Telegram: t.me/nks_HR. Please use the subject: "Translator [English - Target Language]". ⏺Apply: t.me/nks_HR ➖➖➖➖➖➖➖➖➖➖➖ 🪩 Откликнуться быстрее других ➖➖➖➖➖➖➖➖➖➖➖

Airdrop Strikers™

@airdropstrikers · Post #1552 · 02.02.2024 г., 04:30

#DYOR#Advertisement#Indian#Sponsored 💸🎁😳 V I P 2️⃣➕ L U C K Y D R A W 😳🎁💸 rummytryag.com?from_gameid=8197351&channelCode=8184357 ✊Instantly access the⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️⌨️ rewards!🤑 Don't delay, log in now to take part in the Weekly Bonus and claim your substantial rewards!🍀 Deposit 😀₹1️⃣0️⃣0️⃣0️⃣ and seize the exclusive chance to be among the top 2️⃣0️⃣ spots, with each rewarded 😀₹1️⃣0️⃣0️⃣0️⃣. Every Monday 1️⃣4️⃣🔣0️⃣0️⃣0️⃣⏰ 🔴JOIN NOW AND EARN MORE🔴 rummytryag.com?from_gameid=8197351&channelCode=8184357 🎉Enhance your gaming journey with fantastic benefits! Seize the opportunity to enrich your gaming experience.💩

Reuters: World

@reutersworldchannel · Post #149304 · 13.10.2021 г., 14:23

World Court sides mostly with Somalia in border dispute with Kenya The top U.N. top court ruled on Tuesday largely in favor of Somalia in its dispute with Kenya, setting a sea boundary in part of the Indian Ocean believed to be rich in oil and gas. #Somalia#Kenya#UN#ICJ#Indian Ocean #News#Reuters Subscribe: http://smarturl.it/reuterssubscribe Reuters brings you the latest business, finance and breaking news video from around the globe. Our reputation for accuracy and impartiality is unparalleled. Get the latest news on: http://reuters.com/ Follow Reuters on Facebook: https://www.facebook.com/Reuters Follow Reuters on Twitter: https://twitter.com/Reuters Follow Reuters on Instagram: https://www.instagram.com/reuters/?hl=en ➖@reutersworldchannel➖

Trump's Ear

@trumpsear_tg · Post #2158 · 17.02.2026 г., 13:00

In the Indian state of Kerala, the sculptor carved the statue of Trump and Melania as the embodiment of the Indian gods Shiva and Kali. Thus Trump has entered the Pantheon of Hindu gods. #indian#state#kerala#trump#pantheon 👂More on Trump's Ear ⚠️

Desi Memes Funny Jokes

@DESI_MEMES_Funny_Jokes · Post #5423 · 11.10.2024 г., 12:28

🌟EAR BUDS @ ₹39🌟 🔥LOOT DEAL OF THE DAY🔥 🛍Grab fast before it gets Out of stock. Get similar deals in future by joiningLoot Indian Deals🛍 🔰Note- Check all deals instantly 🔰 #Loots#Indian#Deals#offers

Love Nature

@LovelyNature · Post #1587 · 30.05.2021 г., 12:36

"#Tharparkar Cows" - a #Desi#cow breed found mostly in North Western India. "Thar+par+kar" name derives from the fact that they can cross the Thar desert without any difficulty. Hindu #Indian#tharparkar#gomata😍 Join @LovelyNature

Airdrop Strikers™

@airdropstrikers · Post #1592 · 14.02.2024 г., 14:22

🚨Game : TC Games 🤑Refer: High Level Commission 🛃Minimum Deposit : 300Rs 📅Minimum Withdraw : 110Rs 🖥Earn daily : 500-10keasily 🤖Game Link: Join Here 📝Guide: 🔘 Register Using Mobile Number 🔘 Play game and Withdraw and earn High money 🧿Info 🔘 Contact Telegram Support 🔘 Join Telegram Prediction Group1 and Group2 🔘 Only 4-7 Level Sure winning 🔘 Want to become an agent and bonus Contact 🔴Note: Please do your own research (DYOR) before joining to any project.Don't send any fee or penny without doing own research. #TCgames#TcLottery#Indian#inr#TC#Sponsored#Ad

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