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

Резултати

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

Пребарај: #appointments

当前筛选 #appointments清除筛选
@Call News

@call_updates · Post #73 · 09.10.2024 г., 09:58

🆕Appointments here! We glad to present you a 1st version of Appointment system. This journey was challenging, interesting and took 4 months. We faced complex challenges where we had to create a new approach. 🌐 Now you can discover all kind of businesses in one mini app with convenient map. Your country, your service, your time! 🛍 We know that our users want to provide their customers with only the best service that will work 24/7 without interruption. All on one page and app. Provide services and book services from others. The era of Telegram appointments is now open! And don't forget, almost all new businesses will be available for viewing and researching by thousands of Callegram users. Don't miss the opportunity to be the first to create a business! App | #Callegram#MiniApps#Appointments

@Call News

@call_updates · Post #71 · 03.10.2024 г., 06:40

🔜 We're at the finish line! This is what the booking process will look like from the client's side. Choose the time, master and service that is convenient for YOU 👍 App | #Callegram#MiniApps#Appointments

@Call News

@call_updates · Post #68 · 16.09.2024 г., 14:10

✏️Find a Cool Service Directly in @CallegramBot? Why Not? We’re almost here with a new huge update — Appointments. Our users will be trying to find an awesome services directly in the mini app. We’re doing our best! App | #Callegram#MiniApps#Appointments

@Call News

@call_updates · Post #59 · 09.08.2024 г., 13:05

©Appointments: First Impressions This video shows how to create a business and service pages. Soon you will able to provide your offline and online services to your customers with convenient way to book them automatically in a few clicks within Telegram 🗓 We're waiting your comments! App | #Callegram#MiniApps#Appointments

@Call News

@call_updates · Post #78 · 06.11.2024 г., 12:00

🚨AI Takes Your Job And this is awesome! Today we’ve tried our first version of AI Appointments. And it works really great! In the near future your clients will chat with you about services and AI will assist you with confirming appointments. Different languages, text and voice messages. No more annoying work! Be ready for the feature right now. Create your business 🔗t.me/CallegramBot/subscribe_business App | #Callegram#MiniApps#AI#Appointments

@Call News

@call_updates · Post #52 · 03.06.2024 г., 14:30

🔜Appointments In Callegram This is a big part of our service and we want to share with you a first sneak peak. ⚠️ This feature is not available now. Check our news below. Users. You will get an option to make an appointment directly in Telegram for your favorite services. You don’t need to make a call or visit the service location. Just few clicks and you will get what you want + reminders about upcoming service. Businesses. Setup your businesses, locations, specialists, their schedules and services. Automate your handwork and launch your services in Telegram within a few minutes. Marketplaces. If you want to use our Callegram system in your flow and give your merchants opportunity to create an appointment schedule, please contact @krimon 👀 Stay tuned and check the news in our channel #MiniApps#Telegram#Business#Appointments

@Call News

@call_updates · Post #75 · 10.10.2024 г., 15:00

⚙️We've automated everything for you Now your business' schedule is sent automatically if the person writes the words ‘Book’, ‘Appointment’ To activate the function: 1) Create a business with services; 2) Pay subscription; 3) Add @CallegramBot in Telegram settings in "Telegram Business - ChatBots". Now your customers will get a specific message with option to make an appointment. Don't waste time on routine, get down to business. Callegram optimises your work 💰 App | #Callegram#MiniApps#Appointments#TelegramBusiness