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

Резултати

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

Пребарај: #smartphone

当前筛选 #smartphone清除筛选
🦅 [ perspective ix ]

@perspectiveix · Post #1931 · 06.01.2020 г., 13:05

🔋The Smartphones With the Longest-Lasting Batteries Every #smartphone users know the dilemma: It doesn’t matter how great your latest-generation smartphone is or which cutting-edge features it contains - the device still runs on old-fashioned electricity it draws from its battery, often the weakest part of the phone. With the number of apps people use and time they spend on their smartphone increasing, battery woes are all too common - the prevalence of powerbanks and charging stations popping up in different places certainly tell that story. 🦅@PerspectiveIX 📖 Read more on Statista. 🤝Support PerspectiveIX.

Hashtags

🦅 [ perspective ix ]

@perspectiveix · Post #1859 · 04.07.2019 г., 10:30

📱Smartphone Dominance Following up on the poll above, although not producing the same results, here are some interesting stats from Pew Research Centre: #Smartphone users are now more likely to go online using their mobile phone than with some other type of device. For smartphone owners, their mobile devices now outpace more traditional means of accessing the web. 46% of them say when using the internet, they mostly do so on their phone. This represents a 12% increase from 2013 when 34% of these users said this. At the same time, the share of smartphone users who say a desktop, laptop or tablet computer is their primary device for going online has fallen from 53% in 2013 to 30% today. Roughly a quarter of smartphone users say they equally use a cellphone or a desktop, laptop or tablet computer when going online, up from 12% six years prior. 🚀@PerspectiveIX

Hashtags

Home decor

@dzdigital3 · Post #18820 · 07.08.2025 г., 10:27

#Blackview HERO 10 Smartphone 6.9" AMOLED Foldable Screen 12GB 256GB MTK Helio G99 108MP Camera 45W Charge #Smartphone black Link product https://s.click.aliexpress.com/e/_EQp26rj

Home decor

@dzdigital3 · Post #18762 · 02.08.2025 г., 17:58

#Blackview HERO 10 Smartphone 6.9" AMOLED Foldable Screen 12GB 256GB MTK Helio G99 108MP Camera 45W Charge #Smartphone black Link product https://s.click.aliexpress.com/e/_EQp26rj

Home decor

@dzdigital3 · Post #18761 · 02.08.2025 г., 17:58

#Blackview HERO 10 Smartphone 6.9" AMOLED Foldable Screen 12GB 256GB MTK Helio G99 108MP Camera 45W Charge #Smartphone black Link product https://s.click.aliexpress.com/e/_EQp26rj

🦅 [ perspective ix ]

@perspectiveix · Post #1651 · 11.11.2018 г., 10:00

🔈Smart Assistants Usages According to GlobalWebIndex, that functional activities are the leading use case for #Smartphone voice assistant, like asking for directions or for checking the weather. Home assistants, on the other hand, provide a more relaxing and interactive experience. The research also revealed that home assistant users perform a greater variety of behaviors on average, with an emphasis on content and entertainment, like streaming #Music. 🚀@PerspectiveIX via GlobalWebIndex. ❓ In the past month, have you used any Voice Assistants, such as Siri, Cortana, Alexa?

Chollazo Exprés 🔥 Ofertas y Descuentos

@ChollazoExpres · Post #5588 · 07.01.2026 г., 09:30

💥XIAOMI Poco C75 - Smartphone de 8+256GB Potencia y estilo en tus manos ✅OFERTA: 98.0€ ❌ Antes: 151.9€ 💰Ahorras un 35%🔥 Disfruta de una pantalla fluida y cámaras de alta calidad para capturar tus mome 👉 Renueva tu smartphone ahora #xiaomi#smartphone#tecnologia#descuentos#ofertas#viral#rebajas 🛰️Oferta publicada en Tecnología

🦅 [ perspective ix ]

@perspectiveix · Post #1261 · 11.05.2018 г., 19:00

​​📱Have We Reached Peak Smartphone? After a decade of growth, the global #smartphone market came to a standstill in 2017. According to latest estimates from market research firm IDC, a worldwide total of 1,472 million #smartphones were shipped in 2017, virtually unchanged from the 1,473 million units shipped in the previous year. 🚀@PerspectiveIX 🌳https://prs.pctvix.co/2rBpZT1

🦅 [ perspective ix ]

@perspectiveix · Post #1390 · 07.07.2018 г., 19:30

​​📱Apple Regains the Global Best Selling Smartphone Spot With the iPhone 8 According to Counterpoint’s Market Pulse, #Apple regained the top spot in the global best selling #smartphone list with the #iPhone 8. Seems like strong promotions (“How to shoot on iPhone”) running up to the FIFA World Cup helped the tech giant trigger buyer interest in Europe and other markets. iPhone 8 sales were steady in the US postpaid channels. 🚀@PerspectiveIX 📖 via CounterPoint: prs.pctvix.co/2zgwMrv

🦅 [ perspective ix ]

@perspectiveix · Post #1617 · 22.10.2018 г., 09:00

​​📑Q4 2018 Internet Report The next billion doesn’t seem so far anymore! Millions of people across Africa and South Asia came online for the first time in the past three months, with almost all of these new users accessing the #Internet solely via mobile devices. - There are almost 4.2 billion internet users around the world in October 2018, up seven percent since this time last year. - Around 3.4 billion people around the world used #SocialMedia in September 2018, up 10% since September 2017. - More than 5.1 billion people now use a mobile phone, with most using a #smartphone. 🚀@PerspectiveIX via SlideShare (Slide Deck).

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