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

Резултати

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

Пребарај: #multilateralism

当前筛选 #multilateralism清除筛选
Venezuelanalysis

@venanalysis · Post #2243 · 14.01.2026 г., 04:02

🖊OPINION | The Kidnapping of Venezuela’s Sovereignty "The kidnapping of Nicolás Maduro and National Assembly deputy Cilia Flores should compel a fundamental reassessment of the state of the international order." Tricontinental Institute researchers Atul Chandra and Tings Chak look at the recent US attacks and their implications for multilateralism and international law. Follow the link to read the article: https://venezuelanalysis.com/analysis/the-kidnapping-of-venezuelas-sovereignty/ #InternationalLaw#Multilateralism#Sovereignty#NicolasMaduro

Russian Mission to ASEAN

@aseanrussia · Post #374 · 24.04.2023 г., 14:24

🌐Today is International Day of Multilateralism and Diplomacy for Peace. On December 12, 2018, the UN General Assembly passed a resolution A/RES/73/127 on marking this day. The document notes that the International Day aims to promote UN values and to reaffirm the trust of the world’s nations in the goals and principles of the UN Charter. 🇷🇺🇺🇳 Russia is invariably committed to the policy of upholding multilateralism and the UN’s leading role in global affairs and is actively involved in efforts to overhaul the UN and to adapt it to new international realities. This is particularly topical today when a narrow group of states advancing the rules-based order concept exerts unprecedented pressure on the UN and other multilateral institutions. ✍️ Under the Russian Foreign Policy Concept, approved on March 31, 2023, Russia intends to prioritise efforts to reinstate the UN’s role as a central coordination mechanism in coordinating the interests of UN member states. At the same time, one of the main aims of national foreign policy is to strengthen the potential of multilateral regional associations and integration organisations involving Russia. For example, this refers to measures to enhance the international role of #BRICS, the #SCO, the #CIS, the #EAEU, the #CSTO, #RIC and other interstate associations and international organisations, as well as mechanisms with significant Russian involvement. ⏰ Today, on April 24, FM Sergey Lavrov will take part in one of the key events of Russia’s presidency of the UN Security Council, specifically, the open debate on "Effective multilateralism through the defence of the principles of the Charter of the United Nations." The debate will be streamed live on all our feeds. #UNCharterIsOurRules#Multilateralism

Marx21.it

@marx21news · Post #9207 · 14.11.2025 г., 14:44

La Convenzione di Hanoi: un nuovo pilastro globale contro il crimine cibernetico Il 25 ottobre a Hà Nội è stata firmata la Convenzione ONU contro il crimine cibernetico, primo strumento universale che unisce sicurezza digitale, cooperazione giudiziaria e tutela dei diritti umani in un’unica cornice globale. Con quasi 70 Paesi firmatari già nella giornata inaugurale, il trattato segna una svolta nella governance del cyberspazio e un importante riconoscimento del ruolo crescente del Việt Nam come attore diplomatico di primo piano. La “Convenzione di Hanoi” mira a: Armonizzare le definizioni di reati informatici e le procedure investigative. Favorire lo scambio di prove elettroniche e la cooperazione giudiziaria. Proteggere i diritti fondamentali e promuovere la fiducia tra Stati. Rafforzare la sicurezza digitale globale senza sacrificare la libertà online. Per il Việt Nam, ospitare la firma è molto più che un gesto simbolico: è la conferma di una leadership multilaterale proattiva e della volontà di contribuire alla costruzione di un cyberspazio sicuro, equo e aperto. Come ha ricordato António Guterres, “la vera forza della Convenzione sarà trasformare le firme in azione concreta”. Se il mondo saprà cogliere questa opportunità, Hà Nội 2025 resterà nella storia come il giorno in cui la comunità internazionale ha iniziato davvero a mettere legge nel cyberspazio. #HanoiConvention#Cybercrime#UN#Vietnam#DigitalDiplomacy#CyberSecurity#Multilateralism https://www.marx21.it/internazionale/la-convenzione-di-hanoi-come-nuovo-pilastro-globale-contro-il-crimine-cibernetico/

@RusEmbMalta: 🇷🇺🛡️13th International Security Meeting to Be Held in Moscow 📅 On May 27–29, 2025, Moscow will host the 13th International Meeting of High Representatives for Security Issues under the chairmanship of Secretary of the Russian Security Council Sergey Shoigu. 🌍 More than 150 countries from the Global South and East have been invited to participate, along with representatives of the #CIS, #CSTO, #EAEU, #SCO, and over 20 international organizations. 🗂️ The meeting will focus on strengthening international security cooperation. Discussions will cover a broad range of challenges, including terrorism, extremism, transnational crime, drug trafficking, and emerging threats. 🧭 Since 2010, this annual platform has brought together senior security officials to build trust, share expertise, and coordinate efforts on pressing global security issues. 📌 Media accreditation is open until May 20, 2025. #Shoigu#SecurityCouncil#InternationalMeeting#Moscow2025#GlobalSecurity#Counterterrorism#Multilateralism#CIS#SCO#BRICS#CSTO#EAEU#GlobalSouth