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

Резултати

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

Пребарај: #drugtrafficking

当前筛选 #drugtrafficking清除筛选
Venezuelanalysis

@venanalysis · Post #2086 · 02.09.2025 г., 19:10

📑🖊 OPINION | The Great Hoax Against Venezuela: Oil Geopolitics Disguised as ‘War on Drugs’ Former UN anti-drugs agency director Pino Arlacchi dismantles the “narco-state” narrative with 30 years of reliable data. The 2025 UNODC and European Drug Reports confirm Venezuela’s marginal role in global drug trafficking, with no coca cultivation or cartel presence. Arlacchi states the “Cartel de los Soles” is a political fabrication, absent from all international anti-drug reports. 👉🏽 Read the full opinion piece here: https://shorturl.at/69vho #DrugTrafficking#NicolasMaduro

Venezuelanalysis

@venanalysis · Post #2176 · 17.11.2025 г., 23:01

📰 NEWS | Venezuela: Rubio Pushes ‘Foreign Terrorist’ Designation While Trump Floats Maduro ‘Discussions’ The US will designate the alleged “Cartel de los Soles” as a Foreign Terrorist Organization on Nov. 24. Despite repeated accusations, US officials have not presented court-tested evidence tying Maduro or other Venezuelan leaders to drug trafficking. Trump has also raised the possibility of upcoming talks with the Maduro government. This comes as Washington continues a significant military buildup in the Caribbean and has carried out 22 boat strikes that resulted in 83 civilian deaths, without disclosing evidence of the vessels’ cargoes or crews. Read the full report here 👉🏾https://shorturl.at/c7RIV #DrugTrafficking#USMilitaryThreats#USVenezuelaRelations

Venezuelanalysis

@venanalysis · Post #2115 · 27.09.2025 г., 13:00

📑🖊 OPINION | From WMDs to “Narco-states”: How the US Sells Wars the Intelligence Doesn’t Support Analyst Alan MacLeod exposes how Washington's growing attacks against Venezuela are built on biased and evidence-free narratives. The U.S. has escalated its military presence in the Caribbean, with 7 warships, a submarine, an amphibious assault ship, and F-35 jets deployed near Venezuela. However, UN and DEA reports contradict Washington’s claims that Venezuela is a key drug producer. 🔗 Read the full opinion piece here: https://shorturl.at/HnTkw #DrugTrafficking#USMilitaryThreats#USVenezuelaRelations

Venezuelanalysis

@venanalysis · Post #2104 · 15.09.2025 г., 22:13

🎥 VIDEO | ‘All About Oil’: Breaking Down US Military Threats and Drug Trafficking Charges The Trump administration recently escalated military threats against Venezuela, citing drug trafficking as justification. On Breakthrough News, VA's José Luis Granados Ceja explained that these charges lack legal basis and reflect political motives behind Washington’s attacks. 👉 Watch the full video here: https://venezuelanalysis.com/video/all-about-oil-breaking-down-us-military-threats-and-drug-trafficking-charges/ #USVenezuelaRelations#USMilitaryThreats#DrugTrafficking

Venezuelanalysis

@venanalysis · Post #2103 · 15.09.2025 г., 16:25

📰 NEWS | Venezuela Warns US Seeks Regime-Change ‘Provocations’ After US Forces Board Fishing Boat Venezuela condemned the interception of the fishing boat Carmen Rosa by US forces, calling it an “illegal and hostile” act meant to provoke military escalation in the Caribbean. US officials said the operation occurred in international waters after a drug tip that proved false. The incident comes as Washington has deployed thousands of troops, warships, and aircraft to the region, and just weeks after a US strike on a boat near Trinidad and Tobago killed 11 people. 👉 Read the full report here: https://shorturl.at/aonpA #DrugTrafficking#USMilitaryThreats#USVenezuelaRelations

Venezuelanalysis

@venanalysis · Post #2112 · 25.09.2025 г., 20:32

📰 NEWS | Venezuela’s Maduro Moves to Invoke Emergency Powers as US Doubles Down on Its Aggressive Stance Toward Latin America Venezuela is preparing to enact a State of Exterior Commotion, granting emergency powers to the executive in response to US military threats, including naval deployments and lethal strikes in the Caribbean. The Trump administration has redirected $1.8 billion in foreign aid toward a new “America First” strategy, naming Venezuela, Cuba, and Nicaragua as targets. US forces have deployed 4,500 troops, warships, and a nuclear submarine off Venezuela’s coasts. 👉🏽 Read the full report here: https://shorturl.at/8UX2T #ALBA#DrugTrafficking#USVenezuelaRelations

Venezuelanalysis

@venanalysis · Post #2111 · 23.09.2025 г., 21:31

📰 NEWS | Maduro Calls for US-Venezuela Dialogue in Letter to Trump, Refutes Drug-Trafficking Claims President Maduro addressed a letter to Donald Trump calling to “preserve peace” and expressing willingness to resume dialogue through White House Envoy Richard Grenell. Maduro also rejected drug-trafficking allegations against Caracas, pointing to UN and DEA reports that less than 10% of cocaine entering the US transits through Venezuela. 👉🏽 Read the full report here: https://shorturl.at/GIxnk #DonaldTrump#DrugTrafficking#NicolasMaduro#USVenezuelaRelations

Venezuelanalysis

@venanalysis · Post #1932 · 09.04.2025 г., 19:59

📰 NEWS | Six Venezuelan Mayors Arrested in Anti-Drug Crackdown Six mayors—five from the ruling PSUV and one from the opposition—have been arrested in Zulia under “Operation Catatumbo Lightning,” targeting drug trafficking and money laundering. Venezuelan Interior Minister Diosdado Cabello said the network operated on the Maracaibo Lake shores and was tied to far-right figures, including María Corina Machado and Colombian ex-presidents Uribe and Duque. Authorities seized 16 tons of high-purity cocaine, submarines, boats, and dismantled paramilitary camps. Further arrests are expected. 🔗 Read our report here: https://venezuelanalysis.com/news/six-venezuelan-mayors-arrested-in-anti-drug-crackdown/ #DrugTrafficking#ZuliaState

Venezuelanalysis

@venanalysis · Post #2145 · 17.10.2025 г., 10:02

📰 NEWS | Trinidadian Civilians Killed in US Airstrike as Trump Expands Bombing Campaign Near Venezuela Two citizens from Trinidad and Tobago were among six people killed in a US airstrike that destroyed a boat off Venezuela’s coast. The Trump administration said it targeted a drug-smuggling vessel but provided no evidence. Families insist the men were fishermen. The airstrike is part of a broader US bombing campaign in the Caribbean that has killed 27 people since September, drawing condemnation from Colombia and concerns over civilian safety. Read the full report here 👉https://shorturl.at/JsjMM #DonaldTrump#DrugTrafficking#TrinidadandTobago

Venezuelanalysis

@venanalysis · Post #2114 · 26.09.2025 г., 21:35

🎥 VIDEO | War on Drugs Meets War on Terror: Washington’s New Playbook for Latin America Emma Vigeland from Majority Report sits down with Venezuelanalysis’ José Luis Granados Ceja to break down Washington’s latest aggression in Latin America. From the illegal attacks on Venezuelan boats to threats against Mexico, they explore how U.S. policy is once again fueling instability in the region. 👉 Watch the full video here: https://shorturl.at/xbNqS #DrugTrafficking#USVenezuelaRelations#Mexico

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