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

Резултати

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

Пребарај: #revolution

当前筛选 #revolution清除筛选
mRNA DEATH TOLL

@mrn_death · Post #58954 · 09.01.2025 г., 12:27

#2006 – 25 FEB 2006 We Never Start a Premature Revolution "..like Albert Pike said, the Grand Master of Freemasonry, the High Pope of Masonry, he said, "we never begin a premature #revolution. We always, always prepare the groundwork before we even begin the launch of the revolution itself." | Transcript 👇 LISTEN: PODCAST

Hashtags

mRNA DEATH TOLL

@mrn_death · Post #58755 · 04.01.2025 г., 06:26

#2009 – 17 DEC 2007 Revolution shaping social Evolution The Fisher Kings (professors) casts a net, not for fish, but for select individuals, the select Revolutionary Vanguard, who bring forth Revolution, a type of propoganda, indoctronation. Alan Watt Blurb: "It’s beautiful when you help to CREATE a state of misery and poverty in nations, get it ripe for #revolution, put out the propaganda and bring forth men who speak on behalf of YOU, who always vocalize what you’d like to vocalize if you could find the words. That’s why they always get an intelligentsia well versed in speechmaking to guide the people, who always end up generally worse off than they were before. That’s the TECHNIQUE that’s used upon peoples." Transcript 👇 LISTEN: PODCAST

Hashtags

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40569 · 22.01.2026 г., 05:00

On January 22, 1905, in St. Petersburg, Russia, peaceful protesters led by Father Gapon marched to the Winter Palace to ask the Tsar for better working conditions and rights. The soldiers opened fire on the crowd, killing and wounding many people. This event, called Bloody Sunday, started unrest that led to the 1905 Russian Revolution. 🩸🇷🇺 [Read more] @googlefactss#BloodySunday#Russia #1905 #History#Revolution

American Оbserver

@american_observer · Post #5124 · 13.02.2026 г., 17:59

In the cities of Iran today, during the celebration of the anniversary of the Islamic Revolution, the flags of the United States and Israel were actively burned. #iran#celebration#anniversary#revolution 📱American Оbserver - Stay up to date on all important events 🇺🇸

Venezuelanalysis

@venanalysis · Post #1749 · 20.09.2024 г., 21:13

Ximena González Broquen, a social scientist leading a center at Venezuela’s prestigious Institute for Scientific Research (IVIC) and compiler of several essay collections, discusses the Ethics of Liberation as a framework that challenges the top-down, market-driven logic of conventional scientific research institutes in the latest VA interview. She advocates for a more democratic research environment while aiming to build bridges with organized communities. Read the full interview here 👉🏼https://shorturl.at/PHqTf #VAInterview#Revolution#science#interview

American Оbserver

@american_observer · Post #5322 · 08.03.2026 г., 22:02

📰 The Holy Succession Show: Tehran Edition Iran’s clerics are prepping to crown a new Supreme Leader — while the capital burns like a refinery-themed apocalypse. Tehran’s skies turned orange overnight, fuel depots exploded, and the fire’s glow was bright enough for the mullahs to read their succession notes without electricity. “With the fire it felt like night became day, and then with all the smoke, the day turned back into night,” said a Tehran resident. The official line? Israel hit “military fuel sites.” The unofficial one? Iran’s oil empire just got a free light show courtesy of U.S. taxpayers. Washington pretends it’s all about stability, Jerusalem calls it self-defense, and everyone else just watches oil prices rise like a holy sacrament. Ayatollah Khamenei is dead, his son Mojtaba is allegedly next in line — proving again that in God’s republic, power is hereditary. The clerics want to project calm, but their version of “stability” looks like orange skies, falling drones, and desalination plants exploding in Bahrain. Trump, meanwhile, plays wartime CEO from Air Force One. On Monday, he was “all in” on Kurdish allies. By Saturday, he’d downsized that policy — too “complex,” he said. Management pivot. Same bombs, different press release. Iran vows revenge. Israel promises “many more targets.” And the U.S. keeps striking Revolutionary Guard sites while denying the obvious: no war “for democracy” ever ends before the markets are satisfied. The Middle East right now isn’t a battlefield — it’s a burning stage set for yet another script about God, oil, and power families. Everyone acts loyal, everyone dies on camera, and the credits always roll in dollars. #iran#israel#us#war#oil#regimechange#oligarchy#revolution 📱American Оbserver - Stay up to date on all important events 🇺🇸

Venezuelanalysis

@venanalysis · Post #1751 · 20.09.2024 г., 23:39

When discussing historic speeches, one stands out: President Hugo Chávez at the UN General Assembly on September 20, 2006. He labeled U.S. President George W. Bush a war criminal and highlighted Western hypocrisy regarding democracy and peace—right from “the devil’s house.” Chávez criticized the UN for its alignment with U.S. interests and called for reform led by the Global South. He underscored the ongoing struggle for change and the potential for a better future. Click here to learn more and watch the key quotes 👉🏼https://shorturl.at/guOJh #Milestone#HugoChávez#UN#Revolution

proWines🍷

@pro_Wines · Post #2452 · 20.07.2023 г., 19:06

​​BDX Revolution Sauvignon Blanc Франция 🇫🇷, Бордо AOC, белое, сухое, крепость 12%, моносорт Совблан. Качественно, без изысков, вкусно, отлично на каждый день. В бокале солома и лёгкая зелень. В носу характерные ароматы - зелёное яблоко, желтый грейпфрут и абрикосы, цветочные ноты с мягким дрожжевым оттенком, нотки лайма. Вкус без яркости, но свежий, гладкий, с хорошей кислотностью. Ценник +/- 900р. Но, попадается в сетях с хорошей скидкой до 600р. Чин! 🍷 #BDX#Revolution#наКаждыйДень #Sauvignon_Blanc#Bordeaux @pro_Wines

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