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

Пребарај: #potential

当前筛选 #potential清除筛选
America 🇺🇸 News & Politics

@America · Post #10036 · 29.10.2025 г., 02:38

😄Potential ➖➖➖➖➖➖ 🔘 The noun potential refers to the qualities that someone or something has that may be developed and lead to future success. 🔜 He only started the job this year but he has a lot of potential. 🔜 This recipe has potential. It could be perfect if you make some small changes. 🔘 We can also use the noun potential to mean the possibility of something happening. 🔜 These chemicals have the potential to cause lung damage. 🔜 There is potential for further housing developments in the area. 🔘 Potential as an adjective can be used to describe something that could be possible if certain conditions are met. 🔜 Potential customers are waiting for the price to fall before buying it. 🔜 Be careful near the ocean! There's potential danger. #Potential👨‍🏫: @america#americanews ➖➖➖➖➖➖➖➖➖➖➖➖ 🆕 Crypto News @Money 😁 Crypto Game @Egame 🇺🇸 US News @America 🇯🇵 Japan News @Japan 🇦🇪 UAE News @Dubai ▶️ Popular Movies @Videos 😜 Best Funny Video @Funnys

Bahrom Djalilov | Blog

@bahromjon_djalilov · Post #23 · 18.01.2024 г., 09:51

#Ferghana#Potential#IT_Hub Farg'ona viloyati barhavo ob-havosi hamda tirbandsiz yo'llaridan tashqari quyidagi salohiyatga ham ega: - Aholi soni 4 mln. dan ziyod; - Universitetlar soni 13 ta, shundan 3 tasi xorijiy; - AyTi yo'nalishlari mavjud universitetlar soni 7 ta; - Yillik bitiruvchi yoshlar 16 000 nafar; - 17 000 nafardan ortiq yoshlar ingliz tilida, 7 000 dan ortiq yoshlar koreys, 3 000 dan ortig'i xitoy, 2000 dan ortig'i yapon hamda 1600 nafardan ziyod yoshlar nemis tillarini o'rganishga erishgan; - 2000 dan ziyod AyTi sohasidagi hodimlar hamda 70 dan ziyod IT Park rezident korxonalari; - 2,2 million aktiv internet foydalanuvchilarga ega. Yana qanday sohamizga oid zaruriy ma'lumotlar kerak bo'lsa doimiy aloqadabiz. O'sha gap - "Farg'ona oilasiga xush kelibsiz" deb qolaman.

Alien‘s Best Friend

@aliensbestfriend · Post #10563 · 12.03.2026 г., 08:44

Wir sind darauf konditioniert, dass wir dann belohnt werden, wenn wir uns bestmöglich anpassen. Das geht in der Erziehung los, in der Schule wird dann die Anpassung benotet und führt sich fort im gesamten systemischen Leben. Daraus ergibt sich häufig das starke Bedürfnis, anderen gefallen zu wollen oder Wert auf die Meinung anderer zu legen. Aber das ist ein Programm, das uns begrenzt. Wir sollten herausfinden, was WIR wollen, wie WIR zu uns stehen und abprallen lassen, was andere über uns denken. Dann haben wir eine größere Chance, unser Potential auszuschöpfen. Was andere denken, ist nicht Dein Problem. Es ist ihres. Alles Liebe 💜 Nathalie | Alien’s Best Friend @aliensbestfriend #Selbstwert #DeinDing #Potential #Erkenntnis

StartupBase

@startupbaseuz · Post #4702 · 26.10.2024 г., 07:36

Uzbekistan is the right place now to look for growing your business - this message was given by many distinguished panelists at International partnership initiatives week. Only this year the number of companies with foreign capital, who decided to utilize these opportunities to grow their business increased by 250! You can also get the best tax regime upuntil 2040 for ITES companies, affordable talents and low cost of starting your business with the Zero Risk programme in the regions of Uzbekistan: https://outsource.gov.uz Guest Insights: 📌Boris Tadić - former president of Serbia: "Uzbekistan is one of the most #favorable countries for business operations and investments for European companies and IT firms." 📌Raimonds Vejonis - former president of Latvia: "The extension of #benefits for IT Park residents until 2040 will increase investor #confidence." 📌Hamadoun Toure - former head of ITU: “Uzbekistan has taken the leading position in the International Telecommunication Union’s ranking for the most #affordable internet prices.” 📌Akihiro Sakurai: "Uzbekistan has the #potential to supply 300,000 young specialists to the international IT market, generating high incomes." 📌Seán McEllin: “Uzbekistan is becoming the #ideal_location for major IT companies to open their regional offices.” With its forward-looking #digitalstrategy and #commitment to innovation, Uzbekistan is emerging as a dynamic regional hub for international businesses and tech #startups alike. Exciting times ahead for #partnerships and #growth! Uzbekistan is shaping up to be a vibrant regional hub, creating countless opportunities for innovation and foreign partnerships. Follow in Linkedin: https://www.linkedin.com/in/sherzod-shermatov/ #Uzbekistan#ITES#DigitalTransformation#GlobalBusiness#Investment