@WorldNews · Post #73950 · 07.04.2026 г., 18:04
Iran seeks $2 mln vessel fee for Strait of Hormuz passage under its peace plan [Read FullArticle] @WorldNews#IranNews#StraitOfHormuz#InternationalAffairs
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
Пребарај: #internationalaffairs
@WorldNews · Post #73950 · 07.04.2026 г., 18:04
Iran seeks $2 mln vessel fee for Strait of Hormuz passage under its peace plan [Read FullArticle] @WorldNews#IranNews#StraitOfHormuz#InternationalAffairs
@rusembmalta · Post #1762 · 14.11.2024 г., 16:11
🎙 Russia's Foreign Minister Sergey Lavrov’s interview with Marina Kim for the New World project (Moscow, November 14, 2024) Key talking points: #InternationalAffairs • Our main task now is to achieve all the goals formulated by President Vladimir Putin. You are aware of the West’s expectations. They are speculating about stopping the hostilities at a certain line and coordinating a truce, so that 10 years from now they will decide who Crimea and Donbass belong to. This is coffee cup reading. I won’t engage in it. We have our tasks, and we will fulfil them. • Our job is to assert and promote Russia’s interests in keeping with its Constitution as well as the objectives defined by President Vladimir Putin. This goes beyond Ukraine and applies to Russia’s Foreign Policy Concept in general. #USA • Washington can’t allow Russia to prove that it is a strong player and undermine the West’s reputation. They don’t care about Ukraine. They only care about their reputation. They decided that Ukraine should have a government they like and didn’t expect anyone to protest. Russia? It’s a big country but it must be brought down a peg. That is what this is about rather than the future of the Ukrainian people. They don’t care about people. • Sanctions have been imposed on over half of the world’s countries, even if they are not as drastic as those that have been adopted against Russia, the Democratic People’s Republic of Korea, Iran and Venezuela. The real reason behind the West’s current rage is that China is rapidly and confidently surging ahead of the United States. • We can see through what the Americans want. Sitting somewhere overseas, they believe that they are beyond the reach, while leaving it to Europe to overcome the challenges they face in terms of encouraging and arming Ukraine to fight Russia, as well as footing the bill for the Middle East tragedy. #Eurasia4You • God gave us one continent, and we share it. This continent possesses immense and, in fact, the biggest natural resources, while several millennia-old civilisations inhabit it. Failing to benefit from these competitive advantages would be a mistake. This is what the idea of building a Greater Eurasian Partnership is all about, and the EAEU, SCO and ASEAN have already taken the first steps in this direction. We are establishing ties and promoting dialogue. If we succeed in fulfilling the plans we have, the Greater Eurasian Partnership will offer a solid foundation and serve as an economic and transport backbone for what President Vladimir Putin called a new Eurasian security architecture. • There is a clear understanding that the Eurasian security architecture, just like the Greater Eurasian Partnership, must be open to all countries and continents, including Eurasia’s western part, even if so far the latter has been trying, as if by inertia, to ensure its interests within a Euro-Atlantic security concept instead of opting for the Eurasian framework, which would be natural and reasonable, considering the geography factor. This is their way of saying that they do not intend to do anything without the United States. #BRICS 🌐 BRICS is about the new world order that is based on the main principle of the UN Charter – the sovereign equality of states. • BRICS has no intention of dividing the world. It wants to bring together countries that desire closer relations so that they can live on the land they got from God and their ancestors just as they used to, as great civilisations. #Africa 🌍 Decolonisation has taken place, in a broad sense. But being able to actually manage one’s freedom and resources is a different story. This is where neo-colonialism comes to the fore. • The First Ministerial Conference of the Russia-Africa Partnership Forum in Sochi, and the Russia-Africa Summit in St Petersburg in 2023 clearly put into perspective the trends that could be called Africa’s second awakening.