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 слични објави

Пребарај: #environmentalprotection

当前筛选 #environmentalprotection清除筛选
Tkong Channel

@tkong_channel · Post #122 · 22.04.2025 г., 15:15

🌍 Earth Day x Tkong | Walking with the Earth We believe that every action should be rooted in respect for nature. Tkong is deeply committed to our shared home—Earth. 🌀 The image seen here reflects the natural elements within the Tkong logo—oceans, forests, and mountains, all part of our planet. #EarthDay2025#Tkong#EnvironmentalProtection#EarthDay#WalkingWithTheEarth

EKOLOG.UZ| ENG

@ekologuzenglish · Post #11355 · 28.01.2026 г., 07:59

⚠️ AIR POLLUTION IS A SERIOUS CONCERN! In Quvasoy city, Do‘stlik residential area, the 82-KMK reinforced concrete products manufacturing plant is releasing toxic gases and other harmful substances into the atmosphere on a daily basis. This situation poses a real threat to public health and the environment. Under the current circumstances, a legitimate question arises: ❓ How lawful and acceptable is such activity today? We, as members of the public, respectfully but firmly request: 🔹 a thorough investigation of these emissions, 🔹 verification of whether the enterprise operates in full compliance with environmental and sanitary legislation, 🔹 and the adoption of appropriate measures if violations are identified. 🟢 Clean air is not a privilege — it is a fundamental right of every citizen. 🟢 Public health must take precedence over industrial interests. Responsible authorities should not remain indifferent. The public will continue to monitor this situation closely. #AirPollution #Quvasoy #Dostlik #Environment #PublicHealth #EnvironmentalProtection☘️Read the latest environmental news on the @ekologuz page. Follow us and send your suggestions and wishes via @eklguz_bot Instagram | Facebook | Twitter | Sayt | Youtube.

Green University CA | Official

@centralasian_greenuniversity · Post #1028 · 09.04.2026 г., 13:40

Central Asian Ecologists and Eco-Activists Forum at Green University 🔴On April 8, 2026, Green University hosted the Central Asian Forum of Ecologists and Eco-Activists on "Legal Mechanisms for Environmental Protection" in partnership with ‘Yuksalish’ Movement. The forum brought together policymakers, legal experts, environmental specialists, and eco-activists from Uzbekistan and Kazakhstan to discuss evolving environmental policies, law enforcement practices, green urban development, and public participation in decision-making. Experts from Kazakhstan shared insights on Aarhus Convention mechanisms, urban air quality, and eco-startups. 🗣The event featured panel discussions, open debates, and concluded with the presentation of a draft Final Resolution to strengthen environmental governance and legal protection. #GreenUniversity#EcoForum#Sustainability#EnvironmentalProtection 👉ReadMore _________________ Green University’da Markaziy Osiyo ekologlari va eko-faollari forumi bo‘lib o‘tdi 🔴2026-yil 8-aprel kuni Green University'da “Yuksalish” Harakati bilan hamkorlikda "Atrof-muhitni muhofaza qilishning huquqiy mexanizmlari" mavzusida Markaziy Osiyo ekologlari va eko-faollar forumi bo‘lib o‘tdi. Forum O‘zbekiston va Qozog‘istondan kelgan siyosatchilar, huquqshunoslar, atrof-muhit bo‘yicha mutaxassislar va eko-faollarni birlashtirib, atrof-muhit siyosatining rivojlanishi, qonun ijrosi amaliyotlari, yashil shaharlarni rivojlantirish va qaror qabul qilish jarayonida fuqarolik ishtiroki masalalarini muhokama qilish imkonini berdi. Qozog‘istonlik ekspertlar Aarhus Konventsiyasi mexanizmlari, shahar havosining sifati va eko-startaplar bo‘yicha o‘z tajribalari bilan o‘rtoqlashdi. 🗣Tadbir panel muhokamalari va ochiq munozaralar bilan o‘tkazilib, atrof-muhit boshqaruvini va huquqiy himoyani mustahkamlashga qaratilgan yakuniy qaror loyihasining taqdimoti bilan yakunlandi. #GreenUniversity#EcoForum#Barqarorlik#AtrofMuhitniMuhofazaQilish 👉Batafsil ✉️[email protected] ☎️ +998 55 512 00 77 📍Location 🌐Website | 📱Telegram | 📱Instagram | 📱LinkedIn | 🟥YouTube

Green University CA | Official

@centralasian_greenuniversity · Post #559 · 17.12.2025 г., 07:21

Air Quality Assessment in Termez 2025: Toward Cleaner Air and Clearer Skies 🔴On December 16, 2025, Green University, together with UNEP and the Finnish Meteorological Institute, presented the results of the air quality assessment in Termez. The event brought together government representatives, experts, development partners, media, and civil society. 🔴The assessment, conducted at the request of the National Committee on Ecology and Climate Change of Uzbekistan, was based on data from the first automatic reference air monitoring station installed in Termez in 2024 with the support of the Zamin Foundation. The study identified key pollution sources and provided science-based recommendations to improve air quality. 🔴The discussion also covered new air quality management strategies, including the work of Uzhydromet and youth-focused environmental initiatives by the Zamin Foundation. #AirQuality#CleanAir#Termez#Uzbekistan#GreenUniversity#UNEP#FMI#ClimateAction#EnvironmentalProtection ✉️[email protected] ☎️ +998 55 512 00 77 📍Location 🌐Website | 📱Telegram | 📱Instagram | 📱LinkedIn | 🟥YouTube

Green University CA | Official

@centralasian_greenuniversity · Post #1034 · 09.04.2026 г., 13:56

Memorandum Signed Between Green University and “Yuksalish” Movement Within the framework of the Central Asian Forum of Ecologists and Eco-Activists, a Memorandum of Understanding was signed between Green University and “Yuksalish” Movement. 💬The document outlines cooperation in organizing environmental forums, conducting sociological and environmental surveys, supporting innovative startups, and engaging students in volunteer activities. 💬The parties also agreed to expand collaboration through joint research, as well as seminars and conferences. #GreenUniversity#Yuksalish#MemorandumOfUnderstanding#EcoForum#EnvironmentalProtection#Cooperation 👉ReadMore ________________ Green University va “Yuksalish” Harakati o‘rtasida memorandum imzolandi Markaziy Osiyo ekologlari va eko-faollari forumi doirasida Green бUniversity va “Yuksalish” Harakati o‘rtasida O‘zaro anglashuv memorandumi imzolandi. 💬Mazkur hujjat ekologlar forumlarini tashkil etish, sotsiologik va ekologik so‘rovlar o‘tkazish, innovatsion startaplarni qo‘llab-quvvatlash hamda talabalarni volontyorlik faoliyatiga jalb etishni nazarda tutadi. 💬Shuningdek, tomonlar qo‘shma ilmiy tadqiqotlar, seminarlar va konferensiyalar orqali hamkorlikni kengaytirishga kelishib oldi. #GreenUniversity#Yuksalish#Memorandum#EcoForum#AtrofMuhit#Hamkorlik 👉Batafsil ✉️[email protected] ☎️ +998 55 512 00 77 📍Location 🌐Website | 📱Telegram | 📱Instagram | 📱LinkedIn | 🟥YouTube