@fight4f · Post #8275 · 06.05.2024 г., 13:03
荷蘭的英文版每日更新 https://ig.me/j/AbZXhCHKgod1rjEq/ #engels
Hashtags
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
Пребарај: #engels
@fight4f · Post #8275 · 06.05.2024 г., 13:03
荷蘭的英文版每日更新 https://ig.me/j/AbZXhCHKgod1rjEq/ #engels
Hashtags
@druschbaFm_en · Post #52330 · 20.03.2025 г., 08:04
⚡️ 🇷🇺 🇺🇦⚔️ Ukraine Fronts on the Morning of 20 March⚡️ 🔴#Sumy Direction: 🔴In #Sudzha Sector, in the west, fighting continues in and near #Zhuravka, as well as southeast of it in #Basovka on Ukrainian territory. 🟡 In #Kursk region, fierce battles in the areas of the #Gogolevka and #Guyevo villages continue. 📌 Referring to Previous Reports, doubts have arisen as to whether fights are already taking place in the villages. There is still no objective control footage. We have corrected our arrows on map accordingly, which show the control and mentioned locations. 🟡#Oleshnya and #Gornal remain safe under AFU control. 🔴 In #KrasnayaYaruga Sector, south of #Sudhza in Russian #Belgorod region, further massive AFU assaults especially on #Demidovka, as well as in the areas of #Grafovka and #Prilesye have been foiled. The search for the remnants is ongoing. 🗺 All on Map 1 ✈️An AFU F16 was downed. 📌 The AFU Command is reportedly reinforcing all areas and intends to continue also the attacks on #Belgorod region. 🔴 In #Kharkov Direction, without significant changes. 🔴#Svatovo Front: 🔴 In #Kupyansk Sector, fierce fighting along the LoC continues, but without changes. 🔴 In #Borovaya Sector, the battle for #Boguslavka continues. 🔴In #Liman Sector, the RFAF advanced west of the #BalkaZhuravka settlement. 🔴In #Seversk Sector, fights in the area of #Bologorovka (#LPR) and in #Verkhnekamenskoye continue. 🔴#ChasovYar Direction: 🔴In #ChasovYar Sector, the northwestern part of the city is almost completely under Russian control. The battle for the centre southwest of the 'Refractory Plant' continues. Russian troops attacked from the east with armoured vehicles. The result of the battle is disputed. 🗺 Map 2 🎬 Video 1 🔴In #Toretsk Sector, northeast of the city, RFAF units attacked northeast of the #Druzhba settlement towards positions taken by Russian assaults beyond the canal near #Ozeryanovka. 🟡 In #Toretsk itself, the RFAF expanded their zone of control. 🔴#Pokrovsk Direction: 🔴 On the right Flank and south of the city, without significant changes. 🔴 On the left Flank, the battle for #Udachnoye continues as usual. 🟡 In #Uspenovka, the fierce battle continues and towards #Novoalexandrovka southwest of it. 🟡 In #Preobrazhenka, fighting for the eastern settlement part continues. To the south, the Russian troops are attacking towards #Troitskoye and #Bogdanovka. 🔴#Komar Direction: 🔴In #Konstantinopol Sector, the RFAF advanced west of #Slavyanka and north of #Andreyevka, but were driven out of a stronghold northwest of the latter. 🟡 In #Konstantinopol, the battle continues. 🔴 In #Komar Sector, the yesterday reported Russian advance south of #Privolnoye has been confirmed, the fights for the village itself continue. 🔴#Zaporozhye Direction: 🔴In the #Orekhov Section, north of #Rabotino the RFAF attack towards #Novodanilovka and further west in the direction of #Novoandreyevka. 🟡 For #Shcherbaki and #MalyeShcherbaki, the battle continues. 🟡#Stepovoye came, according to unconfirmed reports, under Russian control, as well as heights north of it. 🟡 For #Lobkovoye, the battle has begun with fights in the village (unconfirmed), alternate on its approaches. 🔴 In #Kherson Direction, without significant changes. 💥#OldRussia: 🔵In #Voronezh Region, ca. 40 AFU UAVs were downed overnight. In the #Saratov region, Zelensky tried to raid the Oil Refinery in #Engels, as a result of which the 'City Clinical Hospital No. 1' has been damaged. In the #Rostov region, another UAV attack was repelled. In #Gorlovka (#DPR), 11 civilians were wounded yesterday by Zelensky's morning shelling of the city centre. 💥#RestUkraine: 🔵 In #Kirovograd Region, in turn, after a massive Geranium UAV attack, more than 30 explosions occurred in the town of #Kropyvnytsky. 🎬 Video 2 🎞 Vids Source 1; Source 2; 🗺 Maps @olegtsarov; @creamy_caprice 📋 Sources: CC; Tsarov; ⚡️2M; 🇺🇦Fiend; 😼Kotenok 🕰20 Mar 2025; 06:44 GMT+3; #smo 📱 Join GLOBAL DEPTH to boost your TG Feed 💬Welcome to Military Chat & Ukraine Observer
Hashtags