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

Резултати

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

Пребарај: #drills

当前筛选 #drills清除筛选
bjjfanaticsinstructionals

@bjjfanaticsinstructionals · Post #1853 · 03.08.2025 г., 22:40

😁A Constraints Led Approach to Guard Passing by Standard Jiu Jitsu😁 ➡️A series of games to get coaches and students started developing guard passing skills and designing practices using the constraints led approach. ̶$̶5̶0̶😍$4.99😍 ❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️ 📱Payment: 📱📱📱 💰Submeta FOR FREE 🌈UFC Picks 👑MasterClass ✈️@bjjfanaticsinstructionals #StandardJiuJitsu#Passing#Drills#NoGi 💁‍♀️Buy 💁‍♀️

bjjfanaticsinstructionals

@bjjfanaticsinstructionals · Post #1831 · 17.06.2025 г., 14:51

😁Leg Locks for Beginners by Standard Jiu Jitsu😁 ➡️A collection of games that can be used to start developing leg entanglements and heel hook finishes using the constraints led approach. ̶$̶9̶9̶😍$9.99😍 ❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️ 📱Payment: 📱📱📱 💰Submeta FOR FREE 🌈UFC Picks 👑MasterClass ✈️@bjjfanaticsinstructionals #StandardJiuJitsu#Leglocks#Drills#NoGi 💁‍♀️Buy 💁‍♀️

bjjfanaticsinstructionals

@bjjfanaticsinstructionals · Post #1816 · 24.05.2025 г., 00:01

😁Standing Grappling Games by Standard Jiu Jitsu😁 ➡️A series of games to get you started training the standing grappling scenario using the constraints led approach. $50😍$4.99😍 ❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️ 📱Payment: 📱📱📱 💰Submeta FOR FREE 🌈UFC Picks 👑MasterClass ✈️@bjjfanaticsinstructionals #StandardJiuJitsu#Takedowns#Drills#NoGi 💁‍♀️Buy 💁‍♀️

bjjfanaticsinstructionals

@bjjfanaticsinstructionals · Post #1832 · 20.06.2025 г., 21:04

😁Rides & Escapes Course by Jordan Preisinger and Joe Breza😁 ➡️Use wrestling rides to control, submit, and break free in Jiu-Jitsu! ➡️Wrestling rides are the key to the next level of your BJJ ground game but not a lot of people use them so once you do, you'll have an edge over your teammates who only use Jiu-Jitsu. You'll keep them on the ground, stay on top & submit them... Much more easily. ̶$̶149😍$14.99😍 ❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️ 📱Payment: 📱📱📱 💰Submeta FOR FREE 🌈UFC Picks 👑MasterClass ✈️@bjjfanaticsinstructionals #JordanTeachesJiuJitsu#Wrestling#Drills#NoGi 💁‍♀️Buy 💁‍♀️

American Оbserver

@american_observer · Post #4729 · 29.12.2025 г., 20:58

📰 China’s Record Drills: Taiwan Encircled, World on Edge China just launched its largest war games around Taiwan to date, sending a clear message: Beijing can cut off the island from the outside world if conflict erupts. The drills, dubbed “Justice Mission 2025,” involved troops, warships, fighter jets, and artillery, with live fire and simulated strikes designed to test Taipei’s defenses and U.S.-made weapons. “Conducting live-fire exercises around the Taiwan Strait ... would not only constitute military pressure on us, but could also pose more complex challenges and impacts for the international community and neighbouring countries.” — Hsieh Jih-sheng, Taiwan’s deputy chief of defence The drills covered a record seven zones, some closer to Taiwan than ever before, and forced the cancellation of hundreds of flights. China’s military released propaganda videos showing futuristic tech—automated robots, microdrones, and weaponised robotic dogs—while Taiwan’s defence ministry responded with its own footage of U.S.-made HIMARS rocket systems. Analysts say these exercises blur the line between training and actual preparation for invasion, aiming to give the U.S. and allies minimal warning. China’s state media insists the drills are a response to increased U.S.-Taiwan military cooperation, while Taiwan’s government remains on high alert, coordinating rapid-response exercises and deploying ships to face off with Chinese vessels. So, is this just another show of force—or the opening act of something far more dangerous? #China#Taiwan#warGames#drills#military#Asia 📱American Оbserver - Stay up to date on all important events 🇺🇸