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

Резултати

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

Пребарај: #plantbased

当前筛选 #plantbased清除筛选

Эксперты ВкусВилл дали комментарии об актуальном положении дел сети в сегменте растительных продуктов-аналогов, а также рассказали о планах по развитию категории “Вегетарианское» на 2023 года. «С момента запуска продажи альтернативного мяса и колбасы выросли в 2 раза. Значительный рост продаж год к году наблюдается и в других категориях: молочная продукция (+38%), десерты (+70%), веганская кулинария (+65%). В конце прошлого [2022] года мы решили оставить самый базовый ассортимент и заняться поиском и разработкой новых вкусов. При этом наши постоянные покупатели остались с нами, из чего сделали вывод, что к нам идут за классикой, и нам надо продолжать искать вкусы, которые станут любимым повседневным растительным продуктом. Над новинками мы работаем на постоянной основе, чтобы радовать наших покупателей. Этой весной порадуем на полках ВкусВилла появятся 2 сырокопченые веганские колбасы». Читайте подробнее в статье 😉 @we_are_vkusvill#plantbased

Hashtags

Dishes.Cooking.Food

@cookingdish · Post #564 · 30.10.2024 г., 14:38

🍝 Roasted Vegetables Pasta(4 servings) 🥕 Ingredients 🌶️ 2 peppers 🍅 12 cherry tomatoes 🍄 150 g mushrooms 🧅 3 onions 🧄 6 cloves of garlic 🥒 1/2 zucchini 🧄 Marinade 🫒 Oil as desired 🌶️ 1 tsp chili 🧂 1 tsp salt 🌶️ 1 tbsp paprika 🌿 1 tbsp oregano 🌿 1 tbsp thyme 🖤 Pepper to taste 🥫Sauce 🌱 200 g vegan cream cheese 🍅 2 tbsp tomato paste 🌿 2 handfuls of fresh basil 💧 2 tbsp pasta water 🍇 1 tbsp balsamic vinegar #VeganPasta#RoastedVeggies#PlantBased#HealthyEats @dishes

Dishes.Cooking.Food

@cookingdish · Post #787 · 28.03.2025 г., 14:04

High Protein Vegetable Patties 🥕 Ingredients: - 1 small carrot 🥕 - 1 medium potato 🥔 - 1/2 bell pepper 🌶 - 1 onion 🧅 - 50 g soy granules 🌱 - 50 g corn 🌽 - 50 ml water 💧 - 100 g flour 🌾 - 1 tbsp starch ✨ - Oil for frying 🍳 Preparation: 1️⃣ Grate the carrot & potato, dice the pepper & onion, and place in a bowl 🥣 2️⃣ Soak the soybean granules in water, then add to the bowl along with the remaining ingredients and mix well 👩‍🍳 3️⃣ Shape the dough into patties and sauté in a pan with a little oil until golden brown 🥘 Enjoy! 😋 #HighProtein#VegetablePatties#VeganRecipe#HealthyEating#PlantBased @dishes

Dishes.Cooking.Food

@cookingdish · Post #583 · 17.11.2024 г., 15:23

High Protein Vegetable Patties 🥕 Ingredients: - 1 small carrot 🥕 - 1 medium potato 🥔 - 1/2 bell pepper 🌶️ - 1 onion 🧅 - 50 g soy granules 🌱 - 50 g corn 🌽 - 50 ml water 💧 - 100 g flour 🌾 - 1 tbsp starch ✨ - Oil for frying 🍳 Preparation: 1️⃣ Grate the carrot & potato, dice the pepper & onion, and place in a bowl 🥣 2️⃣ Soak the soybean granules in water, then add to the bowl along with the remaining ingredients and mix well 👩‍🍳 3️⃣ Shape the dough into patties and sauté in a pan with a little oil until golden brown 🥘 Enjoy! 😋 #HighProtein#VegetablePatties#VeganRecipe#HealthyEating#PlantBased @dishes

Dishes.Cooking.Food

@cookingdish · Post #784 · 25.03.2025 г., 14:05

🌿Udon Noodle Bowl 🍜 Ingredients • 🫒 Oil for frying • 100 g smoked tofu 🧆 • 1/2 tsp chili 🌶 • 1/2 tsp thyme 🌱 • 1/2 tsp coriander 🌿 • 2 tbsp soy sauce 🍶 • 100 g mushrooms 🍄 • 2 cloves garlic 🧄 • 300 g udon noodles (pre-cooked) 🍜 Sauce: • 1 tbsp paprika paste 🌶 • 2 tbsp agave syrup 🍯 • 5 tbsp soy sauce 🍶 • 200 ml water 💧 • 1 tbsp starch 🌽 • 1 tbsp white sesame 🥢 Side dishes for the bowl: • 1 bok choy 🥬 • Red cabbage 🥬 • Cucumber 🥒 • Avocado 🥑 • Lime 🍈 • Spring onions 🧅 • Sesame seeds 🌱 • Paprika 🌶 Preparation: 1. 🔥 Fry the smoked tofu in oil, deglaze with soy sauce, season & set aside. 2. 🥄 Mix all the ingredients for the sauce together. 3. 🍄 Sear the mushrooms and garlic, deglaze with the sauce, and stir in the udon noodles. 4. 🍲 Fill the bowl with the udon noodles, tofu, and all the remaining ingredients. #VeganRecipe🌱#UdonNoodles🍜#HealthyEats💚#AsianCuisine🍲#PlantBased @dishes

Dishes.Cooking.Food

@cookingdish · Post #580 · 14.11.2024 г., 14:39

🌿Udon Noodle Bowl 🍜 Ingredients • 🫒 Oil for frying • 100 g smoked tofu 🧆 • 1/2 tsp chili 🌶️ • 1/2 tsp thyme 🌱 • 1/2 tsp coriander 🌿 • 2 tbsp soy sauce 🍶 • 100 g mushrooms 🍄 • 2 cloves garlic 🧄 • 300 g udon noodles (pre-cooked) 🍜 Sauce: • 1 tbsp paprika paste 🌶️ • 2 tbsp agave syrup 🍯 • 5 tbsp soy sauce 🍶 • 200 ml water 💧 • 1 tbsp starch 🌽 • 1 tbsp white sesame 🥢 Side dishes for the bowl: • 1 bok choy 🥬 • Red cabbage 🥬 • Cucumber 🥒 • Avocado 🥑 • Lime 🍈 • Spring onions 🧅 • Sesame seeds 🌱 • Paprika 🌶️ Preparation: 1. 🔥 Fry the smoked tofu in oil, deglaze with soy sauce, season & set aside. 2. 🥄 Mix all the ingredients for the sauce together. 3. 🍄 Sear the mushrooms and garlic, deglaze with the sauce, and stir in the udon noodles. 4. 🍲 Fill the bowl with the udon noodles, tofu, and all the remaining ingredients. #VeganRecipe🌱#UdonNoodles🍜#HealthyEats💚#AsianCuisine🍲#PlantBased @dishes

Dishes.Cooking.Food

@cookingdish · Post #788 · 29.03.2025 г., 14:02

Potato Waffle Burger 🍔🥔 Ingredients: - 6 potatoes 🥔 - 70g all-purpose flour 🌾 - 100 ml plant drink 🥛 - 1 tsp salt 🧂 Toppings: - 2 spreads of vegan cream cheese 🧀 - 1 handful of lamb's lettuce 🥬 - 5 mushrooms 🍄 - Fried onions, chili 🌶 - Agave mustard dressing 🍯 Dressing: - 2 tbsp mustard - 3 tbsp agave syrup 🍯 - 1 tbsp oil 🫒 - 1 tbsp water 💧 - Pinch of salt, pepper 🧂 Preparation: 1. Grate the potatoes, squeeze out the liquid, and mix with all ingredients for the dough. 👩‍🍳🥔 2. Fry the mushrooms and season them. Mix the ingredients for the agave mustard dressing. 🍄 3. Pour the batter into the waffle iron. 🧇 4. Enjoy with the toppings! 😋 #PotatoWaffleBurger#VeganBurger#PlantBased#HealthyEats#EasyRecipes @dishes

Dishes.Cooking.Food

@cookingdish · Post #584 · 18.11.2024 г., 16:24

Potato Waffle Burger 🍔🥔 Ingredients: - 6 potatoes 🥔 - 70g all-purpose flour 🌾 - 100 ml plant drink 🥛 - 1 tsp salt 🧂 Toppings: - 2 spreads of vegan cream cheese 🧀 - 1 handful of lamb's lettuce 🥬 - 5 mushrooms 🍄 - Fried onions, chili 🌶️ - Agave mustard dressing 🍯 Dressing: - 2 tbsp mustard - 3 tbsp agave syrup 🍯 - 1 tbsp oil 🫒 - 1 tbsp water 💧 - Pinch of salt, pepper 🧂 Preparation: 1. Grate the potatoes, squeeze out the liquid, and mix with all ingredients for the dough. 👩‍🍳🥔 2. Fry the mushrooms and season them. Mix the ingredients for the agave mustard dressing. 🍄 3. Pour the batter into the waffle iron. 🧇 4. Enjoy with the toppings! 😋 #PotatoWaffleBurger#VeganBurger#PlantBased#HealthyEats#EasyRecipes @dishes

Venture Village Wall 🦄

@venturevillagewall · Post #3847 · 11.01.2025 г., 10:00

Funding Rounds Roundup: January 2025 Recent funding highlights: - Mindful Health: Raised $5.45M (Jan 7) for mental health services. - WayCool: $4.45M (Jan 9), India's agri-tech leader delivers over 2,000 tons of food daily. - Nevermined: $4M (Jan 9) creates AI-commerce payment infrastructure. - Rybodyn: $4M (Jan 9) to advance medicine development globally. - Rena Labs: Secured $3.3M (Jan 9). - Rebellyous Foods: $2.4M (Jan 9), plant-based chicken products. - Holly: $2.2M (Jan 9) streamlines local government hiring. - Behavix Inc.: Raised $1.66M (Jan 8). - Hypersoniq: $1.14M (Jan 9) in insights measurement. - FuelFWD: $1.03M (Jan 9) for renewable fuel supply chain management. #Funding#MentalHealth#FoodTech#AgriTech#AIPayments#HealthTech#Biotech#PlantBased#GovTech#RenewableEnergy#Compliance#AI#Crypto#VC

Dishes.Cooking.Food

@cookingdish · Post #568 · 02.11.2024 г., 14:24

🌾Oriental Mujaddara 🌾 🌾 Ingredients: 🍚 200g rice 🥫 1 can (300g) cooked brown lentils 🧴 Oil for frying 🧅 3 large white onions 🧅 2 red onions 🧂 Pinch of salt 🥄 150 ml vegetable stock powder 🌿 1 tsp cumin 🧂 Salt and pepper 🍃Yoghurt dip: 🥄 500g soy yogurt 🍋 Juice of half a lemon 🧂 1/2 tsp salt 🧄 2 cloves of garlic 🌿 1 bunch of chives 🌈Toppings: 🌿 Chives, 🍈 pomegranate seeds #OrientalMujaddara#MiddleEasternFlavors#VeganRecipe#PlantBased#ComfortFood @dishes

Dishes.Cooking.Food

@cookingdish · Post #567 · 01.11.2024 г., 15:22

🥬 Asparagus Crêpes 🥞 Ingredients: 🥒 1 bunch of green asparagus 🍋 1 lemon 🧈 200 g smoked tofu 🫒 Oil for frying Crepe Batter: 🌾 200 grams of flour 🌱 50 g lupine flour 🥛 300 ml almond drink 💧 200 ml water 🧂 1 tsp salt 🌟 1 tsp baking powder Hollandaise Sauce: 🧈 15 g margarine 🌾 15 g flour 🥛 150 ml almond drink 🍾 50 ml white wine 🌶️ 1 tsp hot mustard 🥜 1 pinch nutmeg 🧂 Salt & white pepper to taste ✨ Optional: 1 tbsp yeast flakes Toppings: 🌿 Chives, parsley #HealthyEats#AsparagusCrepes#PlantBased#VeganRecipe#Gourmet @dishes

ПретходнаСтраница 1 од 3Следна