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

Резултати

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

Пребарај: #hantavirus

当前筛选 #hantavirus清除筛选
世界新闻 World News 📮

@media_rss · Post #4451771 · 11.05.2026 г., 07:21

Live: Evacuation of hantavirus-hit cruise ship underway A large-scale evacuation has started for passengers aboard a cruise ship stricken by a #hantavirus outbreak. The affected MV Hondius has anchored near Tenerife in Spain, where local health officials arranged orderly disembarkation. The viral outbreak has caused multiple infections and three fatalities. Asymptomatic travelers are prioritized for medical checks before being sent to the airport to return to their nations. The World Health Organization has released surveillance guidelines, advising all evacuated passengers to undergo prolonged health monitoring to stop further transmission. via CGTN

Hashtags

Swiss authorities have confirmed a case of #hantavirus identified in a passenger from the MV Hondius cruise ship. He had responded to an email from the ship’s operator informing the passengers of the health event, and presented himself to a hospital in Zurich, Switzerland, and is receiving care. In line with the International Health Regulations (IHR), WHO is working with relevant countries to support international contact tracing, to ensure that those potentially exposed are monitored and that any further disease spread is limited. The type of virus in this outbreak has been confirmed as Andes hantavirus by the National Institute for Communicable Diseases @nicd_sa, South Africa and the Geneva University Hospitals @hug_ge, Switzerland The support of the Institut Pasteur de Dakar @PasteurDakar, Senegal and the Administración Nacional de Laboratorios e Institutos de Salud @ANLIS_Malbran, Argentina has also been critical in responding to this event. As of 6 May, there are 8 cases, 3 of whom are confirmed as hantavirus by laboratory testing. WHO will continue to work with countries to ensure that the patients, contacts, passengers and crew have the information and support they need to stay safe and prevent spread. X LINK About Hantavirus (spread mainly by rodents)

Hashtags

Swiss authorities have confirmed a case of #hantavirus identified in a passenger from the MV Hondius cruise ship. He had responded to an email from the ship’s operator informing the passengers of the health event, and presented himself to a hospital in Zurich, Switzerland, and is receiving care. In line with the International Health Regulations (IHR), WHO is working with relevant countries to support international contact tracing, to ensure that those potentially exposed are monitored and that any further disease spread is limited. The type of virus in this outbreak has been confirmed as Andes hantavirus by the National Institute for Communicable Diseases @nicd_sa, South Africa and the Geneva University Hospitals @hug_ge, Switzerland The support of the Institut Pasteur de Dakar @PasteurDakar, Senegal and the Administración Nacional de Laboratorios e Institutos de Salud @ANLIS_Malbran, Argentina has also been critical in responding to this event. As of 6 May, there are 8 cases, 3 of whom are confirmed as hantavirus by laboratory testing. WHO will continue to work with countries to ensure that the patients, contacts, passengers and crew have the information and support they need to stay safe and prevent spread. X LINK About Hantavirus (spread mainly by rodents)

Hashtags

Ciencia, tecnología y política 🇦🇷

@cienciaytecnologiaarg · Post #666 · 21.01.2019 г., 23:10

Soberanía Sanitaria 🐦@SoberaniaSalud ____ #Hantavirus: el precio de desfinanciar ➡️Investigadorxs del CONICET cuentan en esta nota qué es lo que faltó, en qué se recortó, y cómo debería actuarse en estas situaciones. Siempre, la importancia de un Estado presente. @RAIIS_ARGhttps://t.co/oqkK5bXcf4 ____ 🔗http://twitter.com/SoberaniaSalud/status/1087361266790871045

Hashtags

America 🇺🇸 News & Politics

@America · Post #10649 · 14.05.2026 г., 13:06

🦠🚨HANTAVIRUS OUTBREAK HITS 36 AMERICANS ACROSS 16 STATES 🔹 16 cruise passengers quarantined at Nebraska Medical Center, 2 more at Emory Atlanta 🚢 🔹 Only known human-to-human hantavirus strain - rare Andes virus with 6-week incubation ⚠️ 🔹 42-day quarantine as 11 cases confirmed globally, 3 deaths, 150 total exposed 💀 🔹 Monitoring in Texas, Georgia, Arizona, Virginia, California with twice-daily checks 🌡️ CDC says pandemic risk 'extremely low' but one French patient on life support This Andes strain killed Gene Hackman's wife - could explode nationwide! 😰 #USNews#Hantavirus @america

Voir de ses propres yeux

@voir_yeux · Post #12780 · 04.05.2026 г., 11:11

🛥️🦠 Trois autres passagers à bord du bateau de croisière MV Hondius ont montré des symptômes du hantavirus, rapporte la chaîne CNN. Précédemment, la BBC, citant des responsables du ministère sud-africain de la Santé, avait rapporté qu’un passager de 70 ans et son épouse de 69 ans, tous deux de nationalité néerlandaise, figurent parmi les victimes d’une possible flambée de hantavirus à bord du paquebot de croisière MV Hondius, qui assurait la liaison entre l’Argentine et le Cap-Vert. Photo: New York Post/X #hantavirus#paquebot#victimes

MALI 24

@kamissokosekou3 · Post #37487 · 04.05.2026 г., 13:13

🛥️🦠 Trois autres passagers à bord du bateau de croisière MV Hondius ont montré des symptômes du hantavirus, rapporte la chaîne CNN. Selon CNN, le navire transportait 170 passagers et 71 membres d’équipage. Il est désormais amarré dans le port de Praia, la capitale du Cap-Vert. Les passagers et l’équipage n’ont pas l’autorisation de quitter le paquebot, des médecins les examinent à bord. Précédemment, la BBC, citant des responsables du ministère sud-africain de la Santé, avait rapporté qu’un passager de 70 ans et son épouse de 69 ans, tous deux de nationalité néerlandaise, figurent parmi les victimes d’une possible flambée de hantavirus à bord du paquebot de croisière MV Hondius, qui assurait la liaison entre l’Argentine et le Cap-Vert. Photo: New York Post/X #hantavirus#paquebot#victimes