Можно ли в 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
Bloom is a nonprofit, volunteer-run organization dedicated to helping women rise from the shadows of abuse and step into the light of healing. Like flowers pushing through the cracks, survivors of domestic violence, physical and sexual assault, and emotional abuse deserve a place to grow, heal, and flourish. Bloom exists to create that space.
While our roots extend to supporting women with mental health struggles, disabilities, cancer, and girls in STEM, our heart is devoted to those who have endured abuse. In Uzbekistan, these issues are often kept hidden—whispered about in the dark when they should be brought into the sunlight. Bloom is here to break the silence, nurture resilience, and help survivors reclaim their strength.
With support from Uzbekistan Volunteers Association (UVA) and Ms. Ceren Guven Gures, Country Programme Manager of UN Women in Uzbekistan, we are planting seeds of change. We stand alongside movements like NeMolchi and Mehrjon, spreading awareness and educating the next generation to recognize and prevent abuse before it takes root.
Healing takes time, but no one should have to do it alone. Together, we can cultivate a future where every woman, no matter her past, can bloom again. Join us, share your story, and help us grow a garden of strength, hope, and renewal. 🌿🌸
#LetHerBloom
Telegram| Instagram
Bloom is a nonprofit, volunteer-run organization dedicated to helping women rise from the shadows of abuse and step into the light of healing. Like flowers pushing through the cracks, survivors of domestic violence, physical and sexual assault, and emotional abuse deserve a place to grow, heal, and flourish. Bloom exists to create that space.
While our roots extend to supporting women with mental health struggles, disabilities, cancer, and girls in STEM, our heart is devoted to those who have endured abuse. In Uzbekistan, these issues are often kept hidden—whispered about in the dark when they should be brought into the sunlight. Bloom is here to break the silence, nurture resilience, and help survivors reclaim their strength.
With support from Uzbekistan Volunteers Association (UVA) and Ms. Ceren Guven Gures, Country Programme Manager of UN Women in Uzbekistan, we are planting seeds of change. We stand alongside movements like NeMolchi and Mehrjon, spreading awareness and educating the next generation to recognize and prevent abuse before it takes root.
Healing takes time, but no one should have to do it alone. Together, we can cultivate a future where every woman, no matter her past, can bloom again. Join us, share your story, and help us grow a garden of strength, hope, and renewal. 🌿🌸
#LetHerBloom
Telegram| Instagram
#LetHerBloom#Announcements
One of our two long-awaited surprises is officially out and around ! Join!
@hotgirlsreadtashkent
🌹🌹🌹🌹🌹🌹🌹🌹🌹🌹🌹
Один из наших двух долгожданных сюрпризов уже в деле! Всё только начинается — присоединятесь !
@hotgirlsreadtashkent
#LetHerBloom#Announcements
We understand that there has been a brief break in Bloom’s activity for the last months and but we are glad to inform that while that break , we have been preparing for not one, but two surprises in the meantime ! So buckle up and get ready for the bombs incoming ✨
Stay tuned…
🌹🌹🌹🌹🌹🌹🌹🌹🌹🌹🌹
Мы знаем, что Bloom немного притих в последние месяцы, но спешим обрадовать вас: всё это время мы не сидели сложа руки, а готовили не один, а целых два сюрприза! Так что пристегните ремни — сейчас прилетят настоящие бомбочки 🔥
С уважением, Bloom Org
📷Instagram | ✈️Telegram
#LetHerBloom#HerLegacy
🌸 Today, we are coming back with our rubric “Her Legacy”, where we dive into lives of women who changed not only theirs, but millions of other women’s lives.
Bloom will tell you who Malala is, her global impact, her achievements, and why she inspires us.
🪄She is the one who taught us that one voice can change revolutions.
Remember:
✨One spark can cause fire that millions of people cannot stop. Be that spark!
💜 Let’s change the world together! Let’s get the strength and change OUR lives.
And after all,
Let Her Bloom!
🚀Telegram | 📷Instagram
#LetHerBloom
#WomenInMedia
🚩From constant criticism to ‘calls’ for a glow up, the media has altered the way women view themselves as a person. Not as a person, not as a beautiful soul, but rather social media prefers us to objectify and constantly push ourselves to look better.
🫵Today, we will explore where and when these unattainable standards come from, what are their roots and most importantly, what we can do about it..
Remember,
you don’t need to be pitch perfect to be loved.
🎈Love yourself the way you are.
📷Instagram | 🚀Telegram
#LetHerBloom
#GretaThunberg
❔What happens when a climate activist speaks out on a global conflict?
💬 Greta Thunberg has always been loud - for the planet, and for the people.
However when she spoke up about Palestine, the silence that followed was different…
On June 9, she boarded humanitarian flotilla the Madleen, planning to deliver aid to Gaza. Israeli forces intercepted the vessel in international waters, detaining and then deporting her by June 10 - after being held in an undisclosed location and pressured to sign documents admitting illegal entry.
‼️ She is back safe, but the reality remains:
Solidarity can come with heavy costs.
🌸 At Bloom, we believe speaking up and fighting is better than staying silent!
So let’s fight for justice and stop traditions of staying silent in unfair situations.
And again,
Let Her Bloom!
#LetHerBloom
#HealthyBoundaries
🕊Setting healthy boundaries: Why they matter and how to start?
At Bloom, we believe that healthy boundaries are the foundation of any respectful and supportive community.
✨In today’s post, we’ll cover:
• What healthy boundaries are
• The different types
• Why they matter
• And how to start setting them with clarity and confidence
✍️
A reminder
Putting your boundaries, self-respect, and emotional well-being first isn’t selfish — it’s how you stay honest with yourself and others.
You are your first responsibility.
🤩
Just like a flower needs sunlight, water, and good soil to grow,
you need care, space, and respect to thrive.
Start with yourself—
and everything else gets stronger too
Let Her Bloom 🌸
🚀Telegram|📷Instagram
#LetHerBloom
#RedFlagsGreenFlags
RED FLAGS 🚩 vs GREEN FLAGS ⏺
Whether it’s a friendship, a relationship, or just how people treat each other — every small behavior speaks volumes. It’s not always about big, dramatic moments. Sometimes it’s the quiet, repeated patterns that tell you everything you need to know.
🌸 In this video, we’re breaking down some of the most common red and green flags to look out for.
Some might make you smile, some might hit a little too close to home.
💬What are YOUR biggest red or green flags? Drop them in the comments — let’s build a list together.
💐 Stay aware. Stay kind. Stay smart.
🚀Telegram | 📷Instagram
#LetHerBloom
#ImpactOfAbuseOnMentalHealth
💐Abuse doesn’t always leave bruises that we can see — but the impact it leaves on someone’s mental health can be deep and lasting.
Today, we’re opening up a conversation about how abuse — whether emotional, physical, verbal, or psychological — can affect someone’s well-being both in the short and long term.
From anxiety and PTSD to feelings of isolation and low self-worth, these are not just experiences to “get over” — they are real results that deserve support, care, and love.
Let’s stop minimizing what we cannot see.
If you are a survivor 🕊
We hear you.
We believe you.
Your healing matters.
You are not alone.
If you know someone who is struggling 🫂
Your presence, your empathy, and your words can be life-changing.
Sometimes, showing up is enough.
Let yourself BLOOM! 🌸
🚀Telegram |📷Instagram
#LetHerBloom
#Abuse101
💐Today we will talk about Abuse. What is abuse? What are the signs of it? And Is it possible to heal from it?
✨ There are so many stereotypes about going through this tough experience. However only those who have been there know the cost.
✨ But there is something we should all know: It is possible to heal from it. With love, support, and strength, women can make a change, without losing hope.
💐Everyone has ability to start fresh. You just have to let Yourself Bloom!
🚀Telegram|📷Instagram
#LetHerBloom#BloomTogether#MentalHealthAwareness#AbusePrevention#HerLegacy
🌸Introducing Bloom’s New Rubric Series🌸
We’re launching a fresh series of posts to raise awareness, educate, and create conversations that matter. Here’s what you’ll see on our page:
✨ Abuse 101 – A breakdown of the different types of abuse.
🚩⏺ Red & Green Flags – What’s healthy vs. what’s harmful in relationships.
🧠 Mental Health Impact – The emotional cost of abuse.
🤝 If You Think Someone’s Being Abused – What to do and how to help.
💐 Her Legacy – Stories of powerful women who changed the world.
🌿 Healthy Boundaries – Why they matter and how to set them.
🎬 Feminism in Media – Representation, reality, and rewriting the narrative.
Stay tuned, stay aware, and let’s keep growing together 🌱💜
🚀Telegram📷Instagram