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

Резултати

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

Пребарај: #beginner

当前筛选 #beginner清除筛选
Repositorio data science

@repo_science · Post #3454 · 19.07.2023 г., 18:01

#powerBI#Beginner 📊 Microsoft Power BI - Complete Beginners Guide to Financial Dashboards Microsoft PowerBI is Microsoft’s new business intelligence tool. I will guide you from downloading and installing Microsoft Power BI Desktop to creating reports and dashboards with a sample data set. 🔗Link ----- Main channel:@repo_science Coupons:@freecoupons_reposcience -----

Repositorio data science

@repo_science · Post #3452 · 19.07.2023 г., 02:11

#powerBI#Beginner 📊 Microsoft 365 Power BI- Beginner This course begins the Power BI Desktop journey with an introduction to self-service business intelligence. The basics are addressed by connecting to data and preparing it for formal analysis. Considering what makes a good visual comes next followed by a number of visuals. Finally a dashboard is created in the Power BI Service with interactivity. 🔗Link ----- Main channel:@repo_science Coupons:@freecoupons_reposcience -----

Pensive|

@PensivePost · Post #4928 · 14.02.2021 г., 11:39

Once again ! Once again someone came and went Shattered my heart once again Yeah it was me Who built bunch of expectations But I just followed my heart once again I know she was worthy enough to fall for But that's not how goes life's cart, once again I wanted to confess this time too But yeah; in race of this hiding emotions I proved that I'm smart once again Brain said Stupid go and study But it wasn't heard by heart once again Did my best to stop it But uncontrollable was my Emotional dart, once again I tried decorating it by all mean But I guess this wasn't my chart once again I know it's a bit difficult to digest But yummy was this tart once again Well it's done now Let's have a new start once again Yess people come and go In someone we will find our part once again It's okay to end this now Beacuse; that's after end Where something new start once again Dear heart it's okay Just start behaving like heart once again So I guess I'm free now Feeling the freedom athwart once again And it's going to be Me only So I won't let anyone impart once again Dear heart please Now start behaving like heart once again What did u just say U r missing her Don't u dare to start mr. Heart once again Once again I fell for someone And yeah We simply fell apart once again ! #review#poetry#beginner#anniii

English Speakers

@English_Speakers · Post #5139 · 23.12.2022 г., 16:46

#converisation #Beginner #Daily_life @English_speakers ⚜➖⚜➖⚜➖⚜➖⚜➖ A: I’m going to take a nap. B: You should unplug the phone. A: That’s a good idea. B: Do you want me to wake you in an hour? A: No, thanks. Just let me sleep until I wake up. B: I’ll start dinner at 6:00. A: Okay. I think I’ll be awake by then. B: If not, your nose will wake you up. A: You mean I will smell the food cooking? B: You might even dream about dinner A: I don’t think I’m going to dream about anything. I’m really tired. B: Have a nice nap. Listen and practice 👇

Dasturlash hayoti️️ ️

@dasturlash_hayoti · Post #4101 · 15.12.2025 г., 13:15

#Dasturlash#IT#Beginner#futurecoder#OnlineLearning futurecoder — dasturlashni noldan o‘rganish uchun mukammal platforma futurecoder — bu hech qanday tayyorgarliksiz dasturlashni boshlash mumkin bo‘lgan bepul va interaktiv ta’lim sayti. Platforma foydalanuvchini asta-sekin fikrlashga, kod yozishga va muammolarni hal qilishga o‘rgatadi. Qanday o‘rgatadi? — Brauzer ichida kod yozish va ishga tushirish — Interaktiv topshiriqlar va real misollar — Har bir mavzu bo‘yicha aniq va sodda tushuntirishlar — Qiyinchilik darajasi bosqichma-bosqich oshirib boriladi Afzalliklari: — Dastur o‘rnatish shart emas — Amaliyotga yo‘naltirilgan — O‘rganish jarayonida xatolarni tushuntirib beradi — Mustaqil o‘rganish uchun juda qulay Kimlar uchun mos? — Dasturlashni endi boshlayotganlar — Python’ni tez va tushunarli o‘rganmoqchi bo‘lganlar — O‘qituvchilar va mentorlar — Amaliy mashqlar orqali bilim olishni istaganlar Rasmiy sayt: 👉https://futurecoder.io/ 💻@dasturlash_hayoti— dasturchilar hayoti va IT memlari aralash kanal😉

GitHub Trends

@githubtrending · Post #14891 · 01.07.2025 г., 11:30

#other#beginner#contribution#contributions_welcome#css#frontend#hacktoberfest#html#javascript#open_source#opensource#php#projects#python#react You can find a well-organized collection of coding project ideas divided into three skill levels: beginner, intermediate, and advanced. Each project includes clear goals, user stories, optional bonus features, and helpful resources, making it easier for you to build and extend your projects. This helps you improve coding skills, experiment with new technologies, and create impressive portfolio pieces to attract employers or clients. The list covers various technologies like JavaScript, Python, React, MERN stack, and blockchain, with tutorials and design resources included. You can also contribute ideas and examples to grow the collection and get community support. This resource saves you time and inspires your learning journey. https://github.com/The-Cool-Coders/Project-Ideas-And-Resources