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

Резултати

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

Пребарај: #hairstyle

当前筛选 #hairstyle清除筛选
In Voga | Fashion & Web 3.0

@invogafashion · Post #3259 · 20.10.2022 г., 11:02

We return the heading of simple hairstyles on Thursdays😉 And next, we have a high tail and a couple of braids. If the density of the hair allows, then more than two is possible. #hairstyle

Hashtags

In Voga | Fashion & Web 3.0

@invogafashion · Post #2779 · 02.06.2022 г., 12:37

Today I will tell you one more elementary way to style your hair (and yes, it works even if it is not too clean😉 and even if there is not a lot of time) - a low tail/pigtail. There is only one rule - we "hook" the hair as low as possible at the neck, and then - whoever is in what much: - pigtail - leave fluffy and straight, and cover the elastic with a strand of hair - rewind with laces -leave fluffy and add some waves - artificial chaos - add bows and ribbons Inspiration attached👆🏼 #hairstyle

Hashtags

In Voga | Fashion & Web 3.0

@invogafashion · Post #2745 · 28.05.2022 г., 12:11

Hairpins everywhere, hairpins in large quantities, hairpins of various types and types, hairpins in any way - this summer, we are experimenting with hairpins, and we are not afraid to overdo it 😉 A few ideas above👆🏼😉 #hairstyle

Hashtags

In Voga | Fashion & Web 3.0

@invogafashion · Post #2673 · 19.05.2022 г., 13:04

If you suddenly decide to impress everyone with your hair, I suggest taking a incredible work by Mitsuki Jurk as a reference. Hollywood wave with pigtails, asymmetric tails, and braids, geometric parting, a mix of different types of braids, braids + natural flowers🌸🌼🌺🌹🌷 When the head and hair are like a picture 🖼, and the hairdresser is like an artist 👩‍🎨 #hairstyle

Hashtags

In Voga | Fashion & Web 3.0

@invogafashion · Post #849 · 16.08.2021 г., 12:02

One of my good friends cut her hair yesterday, and when I saw her, I thought - to the wolf regiment of thousands of TikTok and Instagram bloggers 🐺 has been added another one. And today, a little about this trend. Wolfcut🧑🏻‍🦰 is the most fashionable haircut for summer 2021 that came to us from Korea. Strictly speaking, this is a mixture of 2 haircuts: mullet and shaggy. With wolf cut, the hair is cut in layers from the crown, and bangs are made (these are shaggy features), but at the back of the head, the hair is left long (borrowed from mallet) - it turns out like wool from wolves, which is slightly longer at the withers. Suitable - thin, but thick enough hair, on too thin hair it is necessary to achieve volume is difficult, and as a result, a completely different story turns out. The strands are stacked from the face. The general appearance of the hairstyle is always disheveled and a little messy. #hairstyle

Hashtags

In Voga | Fashion & Web 3.0

@invogafashion · Post #741 · 27.07.2021 г., 13:06

And here are some more examples on the topic of the previous hairstyle for the summer: - pigtails can be slightly perceptible and have very weak weaving, -can be located not only nearby the face but also a little further along with the top layer of the hairstyle, -and you can braid them, as in the first photo, but the truth is then such a hairstyle cannot be called fast and easy😂 Happy experiments! 😉 #hairstyle

Hashtags

In Voga | Fashion & Web 3.0

@invogafashion · Post #740 · 27.07.2021 г., 11:33

Leonie Hanne reminds us that summer☀️ is the perfect time for fine braids nearby our beautiful eyes: ✔️ it is comfortable and hair does not get into the eyes👍🏼 ✔️ conceptually and summerly ✔️ relevant in summer 2021👌🏼 #hairstyle

Hashtags

In Voga | Fashion & Web 3.0

@invogafashion · Post #1704 · 04.01.2022 г., 12:32

It seems absolutely all influencers are obsessed with headbands😍 The undisputed leaders among brands are Prada, Fendi, Simone Rocha, but the rest are quickly catching up. Unambiguously like from me👍🏼 Today there is a new street style. Let's inspire ❤️ #inspirationINVOGA #hairstyle

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