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

Пребарај: #techleadership

当前筛选 #techleadership清除筛选
AI & Law

@ai_and_law · Post #336 · 21.06.2024 г., 07:04

Appian CEO Challenges AI Industry to Prioritize Trust Matt Calkins, CEO of Appian, has called on the AI industry to prioritize responsible development and trust. At a critical moment for AI, Calkins unveiled guidelines promoting data transparency, user consent, and respect for intellectual property. "We must ensure AI flourishes by building trust," Calkins stated. His four principles include disclosing data sources, using private data with consent, anonymizing personally identifiable data, and compensating for copyrighted information. These steps aim to shift AI development from a data race to a trust race. As AI faces increasing scrutiny, Calkins positions Appian as a leader in responsible AI, encouraging others to join this movement. Trust, he argues, will unlock AI's full potential and redefine industry success. #AI#ResponsibleAI#DataPrivacy#Appian#TechLeadership

INHA University in Tashkent

@inha_uz · Post #10083 · 13.02.2026 г., 09:44

🚀 ICT WEEK UZBEKISTAN 2026 The future isn’t coming. It’s being built — right here, right now. This September, Tashkent becomes the meeting point of global innovation. Visionary leaders, fast-growing startups, top tech companies, policymakers, and international partners will gather to shape the next era of digital transformation in Central Asia and beyond. 🌍 Discover breakthrough technologies 🤝 Meet decision-makers and global partners 💡 Turn bold ideas into real projects 📈 Unlock new markets and opportunities This is not just an event. Whether you are a government leader, investor, entrepreneur, tech professional, or innovator — ICT Week Uzbekistan is where you need to be. ✨ Why attend? ✔️ High-level networking with global tech leaders ✔️ Startup & innovation showcases ✔️ Strategic forums and policy dialogues ✔️ Investment and partnership opportunities ✔️ Access to the fast-growing Central Asian tech market 📍 Tashkent, Uzbekistan 📅 September 22–25, 2026 Be part of the conversations that will define your tomorrow. Join ICT Week Uzbekistan 2026. Let’s connect. Let’s collaborate. Let’s build the future — together. #ICTWeekUzbekistan2026#ICTWeek#DigitalTransformation#Innovation#TechLeadership#CentralAsia#FutureIsNow#Uzbekistan

IT Ladies Uzbekistan

@itladiesuzbekistan · Post #257 · 09.02.2026 г., 14:44

🚀 ICT WEEK UZBEKISTAN 2026 The future isn’t coming. It’s being built — right here, right now. This September, Tashkent becomes the meeting point of global innovation. Visionary leaders, fast-growing startups, top tech companies, policymakers, and international partners will gather to shape the next era of digital transformation in Central Asia and beyond. 🌍 Discover breakthrough technologies 🤝 Meet decision-makers and global partners 💡 Turn bold ideas into real projects 📈 Unlock new markets and opportunities This is not just an event. Whether you are a government leader, investor, entrepreneur, tech professional, or innovator — ICT Week Uzbekistan is where you need to be. ✨ Why attend? ✔️ High-level networking with global tech leaders ✔️ Startup & innovation showcases ✔️ Strategic forums and policy dialogues ✔️ Investment and partnership opportunities ✔️ Access to the fast-growing Central Asian tech market 📍 Tashkent, Uzbekistan 📅 September 22–25, 2026 Be part of the conversations that will define your tomorrow. Join ICT Week Uzbekistan 2026. Let’s connect. Let’s collaborate. Let’s build the future — together. #ICTWeekUzbekistan2026#ICTWeek#DigitalTransformation#Innovation#TechLeadership#CentralAsia#FutureIsNow#Uzbekistan

Venture Village Wall 🦄

@venturevillagewall · Post #3969 · 24.01.2025 г., 10:00

Trump Signs AI Development Plan President Trump has signed an executive order to establish the U.S. as the world leader in AI. A 180-day deadline is set for creating an AI Action Plan aimed at strengthening America's global dominance in this field. Additionally, Trump has tasked his AI advisor to eliminate policies from the previous administration. This announcement was made during his speech at the World Economic Forum, affirming plans for leadership in AI and cryptocurrency. For more details, check the full articles: Forklog News #AI#Crypto#Policy#TechLeadership #AI#Crypto#Policy#TechLeadership#Trump#Innovation#Economy#NationalSecurity#ExecutiveOrder#Davos#ActionPlan#America#FutureTech#Leadership#GlobalDominance

Venture Village Wall 🦄

@venturevillagewall · Post #3903 · 17.01.2025 г., 13:00

Market Trends Impact Developer Salaries Developers face salary stagnation as the job market grows competitive. With more candidates than job openings, mid-senior professionals find job switches yield minimal salary increases. Becoming a tech lead is rare and corporations limit hiring senior candidates. Stability may lie in entrepreneurship or pet projects instead. Consider exploring these options for long-term financial health. #JobMarket#DeveloperSalaries#Entrepreneurship#PetProject#IT#CareerGrowth#TechIndustry#EmploymentTrends#SalaryTrends#BusinessModel#Stability#Competition#JobSwitch#MidCareer#SeniorDevelopers#MarketAnalysis#ITCareers#FinancialPlanning#TechJobs#Startup#TechLeadership