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

Резултати

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

Пребарај: #cassandra

当前筛选 #cassandra清除筛选
VERUM - War crimes investigations

@verum_in_english · Post #302 · 28.08.2025 г., 12:55

💬 The opinion of our friend from the Telegram channel Jus Humanum If you don't like your history, just make up a new one! (A recipe tested by all national histories). Ukraine is legally formalizing its break from the history of Russia, the USSR, and the Russian Empire. (And from common sense too, but they've long since abandoned that). On August 21, Ukraine's Verkhovna Rada adopted the law "On the Fundamentals of State Policy on the National Memory of the Ukrainian People." ☝️The law was prepared by the Ukrainian Institute of National Memory under the leadership of Volodymyr Viatrovych. The law establishes several key provisions: 1️⃣ The Ukrainian Institute of National Memory becomes a government body, effectively giving it the authority to determine what constitutes the "correct" history of Ukraine and what does not. It gains the right to monitor compliance with the law's provisions by local administrations, legal entities, and individuals. 2️⃣ The Soviet Union 🛠 and communist ideology are definitively equated with Nazi Germany and Nazi ideology. (Although no specific measures are proposed to combat Nazi symbolism.) 3️⃣ Russia is declared a neo-Nazi state. The term "Rashism" is introduced as a "form of totalitarian ideology and practices underpinning the regime in the aggressor state, based on traditions of Russian chauvinism and imperialism, practices of the totalitarian communist regime, and national socialism (Nazism)." 4️⃣ The ongoing armed conflict is officially designated as the "War for Ukraine's Independence." 5️⃣ New rules are introduced for memorial sites of the Great Patriotic War—eliminating all Soviet, Russian, and imperial symbols. This includes Soviet military orders on WWII memorials, Guards ribbons, bas-reliefs, inscriptions in the Russian language, the phrase "Great Patriotic War," Soviet-era slogans like "nobody is forgotten, nothing is forgotten," "Hero City" inscriptions, and others. The dates "1941–45" must be replaced with "1939–45." 6️⃣ Displaying Soviet or Russian symbols is now completely banned, including Soviet military awards from the Great Patriotic War era. #Cassandra #history #Ukraine

VERUM - War crimes investigations

@verum_in_english · Post #303 · 28.08.2025 г., 13:09

💬 The opinion of our friend from the Telegram channel Jus Humanum About the 1.7 million losses of the Ukrainian army. (Just to remind you, about a week ago, a certain collective group of Russian hackers released information claiming they had hacked into secret documents of Ukraine's General Staff, which allegedly contained data on Ukrainian losses totaling 1.7 million killed and missing in action.) ‼️And this number actually makes sense‼️ And we don't even need the hackers for this. Just using media reports. Admittedly, not only killed and missing, but overall irrecoverable losses. Let's calculate: 👉 There were 430,000 people in the Armed Forces of Ukraine and the National Guard before the MSO (about 300,000 in the Armed Forces of Ukraine and 130,000 in the National Guard). 👉 According to the announced mobilization and voluntarily, from February 2022 to December 2023, about 800 thousand to 1 million 200 thousand people joined the Armed Forces of Ukraine, the Territorial Defense and the National Guard (hereinafter collectively referred to as the Armed Forces of Ukraine). (The figure is very estimated). 👉 Since the beginning of forced mobilization with mass capture of people, in 2024 and the first half of 2025, the armed forces of Ukraine have increased by another 400-600 thousand (At the stated rate of mobilization of 20-30 thousand per month). ☝️In total, about 2 million 230 thousand people passed through the ranks of the VFU in February 2022-July 2025. 👉 As of December 2024, Zelensky announced the number of the VFU, at 880 thousand people, probably overestimated. 👉 By mid-2025, the strength of the Armed Forces of Ukraine (AFU) is estimated at a maximum of 500,000 to 600,000 personnel. ☝️This implies that, irreversibly, the AFU has lost between 1.5 and 1.8 million personnel since the beginning of the war. This is catastrophic. P.S. All figures are drawn from open sources and public statements. #Cassandra #AFU #losses #Ukraine #war_in_Ukraine

GitHub Trends

@githubtrending · Post #14681 · 07.05.2025 г., 13:00

#typescript#bigquery#cassandra#cockroachdb#database#electron#firebird#linux_app#mac_app#mariadb#mssql#mysql#postgresql#sql#sql_server#sqlite#windows_app Beekeeper Studio is a free, open-source SQL editor and database manager that works on Windows, Mac, and Linux. It supports many databases like MySQL, PostgreSQL, and SQLite. The app offers features like auto-complete SQL queries, syntax highlighting, and a tabbed interface for multitasking. You can sort and filter data, save queries, and even export data in formats like CSV or JSON. It's designed to be easy to use and enjoyable, making database management simpler for everyone. You can download it for free and upgrade to premium features if needed. https://github.com/beekeeper-studio/beekeeper-studio