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

Пребарај: #gretathunberg

当前筛选 #gretathunberg清除筛选
Bloom Org

@bloomorg_uz · Post #51 · 12.06.2025 г., 14:25

#LetHerBloom #GretaThunberg ❔What happens when a climate activist speaks out on a global conflict? 💬 Greta Thunberg has always been loud - for the planet, and for the people. However when she spoke up about Palestine, the silence that followed was different… On June 9, she boarded humanitarian flotilla the Madleen, planning to deliver aid to Gaza. Israeli forces intercepted the vessel in international waters, detaining and then deporting her by June 10 - after being held in an undisclosed location and pressured to sign documents admitting illegal entry. ‼️ She is back safe, but the reality remains: Solidarity can come with heavy costs. 🌸 At Bloom, we believe speaking up and fighting is better than staying silent! So let’s fight for justice and stop traditions of staying silent in unfair situations. And again, Let Her Bloom!

Reuters: World

@reutersworldchannel · Post #149256 · 12.10.2021 г., 15:43

Greta Thunberg talks about her life Staying grounded makes coming back to normal life easier, climate activist Greta Thunberg says, as she talks about her handling of fame. #News#Reuters#GretaThunberg#lifestyle Subscribe: http://smarturl.it/reuterssubscribe Reuters brings you the latest business, finance and breaking news video from around the globe. Our reputation for accuracy and impartiality is unparalleled. Get the latest news on: http://reuters.com/ Follow Reuters on Facebook: https://www.facebook.com/Reuters Follow Reuters on Twitter: https://twitter.com/Reuters Follow Reuters on Instagram: https://www.instagram.com/reuters/?hl=en ➖@reutersworldchannel➖

Freedom Flotilla Coalition

@FFC_official_channel · Post #525 · 10.06.2025 г., 18:49

Some snippets from Greta’s interview after being deported by Israeli authorities. Continue fighting for Palestinians in Gaza, including those in wider Palestine who are unlawfully imprisoned, including over 400 children. #Madleen#IOF#GretaThunberg#FreedomFlotilla

Savino Balzano

@savinobalzano · Post #1181 · 05.10.2025 г., 17:25

https://x.com/SavinoBalzano/status/1974887738919772654 Penso davvero che #AntonioTajani rappresenti uno dei punti più bassi della storia della diplomazia italiana. Uno che va in televisione a dire che il diritto internazionale conta fino a un certo punto. Uno che parla di “abordaggi pacifici”. Uno che sottolinea come i nostri concittadini non siano stati trattati da #Israele come terroristi. A parte il fatto che mente spudoratamente: da quanto emerge, le condizioni di detenzione sono state inaccettabili e, soprattutto, gli israeliani si sono accaniti sulle persone trattenute con azioni a dir poco intollerabili. Vale però la pena ricordare, ancora una volta, che i membri della #Flottilla non stavano commettendo alcuna azione illegale. Erano in acque internazionali (acque di tutti e di nessuno) e, soprattutto, del tutto disarmati. Per quanto ci riguarda, i nostri concittadini erano anche su imbarcazioni battenti bandiera italiana, dunque su territorio della Repubblica. La stessa Repubblica di cui, purtroppo (per quanto mi riguarda), #Tajani è ministro. Ora mi rivolgo a tutti, anche agli amici di destra. Gli attivisti possono anche esservi antipatici (personalmente non ho mai nutrito alcuna simpatia per #GretaThunberg), ma non comprendere che tenere la gente in carcere illegalmente, affamarla e assetarla, costringerla a baciare la bandiera israeliana in una cella infestata dalle cimici, sia semplicemente barbaro, vi rende peggiori di chi più vi ripugna. Sia chiaro. E qualcuno ha ancora il coraggio di parlare dell’unica democrazia del Medio Oriente? Ma con che faccia? #BattitoriLiberi: dal lunedì al venerdì alle 17, su Radio Cusano

Reuters: World

@reutersworldchannel · Post #149513 · 18.10.2021 г., 14:46

Greta grooves at Stockholm climate concert Swedish climate activist Greta Thunberg surprised the crowd at the Climate Live concert in Stockholm by delivering a dance rather than a speech. #News#Reuters#GretaThunberg#Stockholm#RickAstley Subscribe: http://smarturl.it/reuterssubscribe Reuters brings you the latest business, finance and breaking news video from around the globe. Our reputation for accuracy and impartiality is unparalleled. Get the latest news on: http://reuters.com/ Follow Reuters on Facebook: https://www.facebook.com/Reuters Follow Reuters on Twitter: https://twitter.com/Reuters Follow Reuters on Instagram: https://www.instagram.com/reuters/?hl=en ➖@reutersworldchannel➖

la fionda📗

@lafionda · Post #6652 · 05.10.2025 г., 17:57

https://x.com/SavinoBalzano/status/1974887738919772654 Penso davvero che #AntonioTajani rappresenti uno dei punti più bassi della storia della diplomazia italiana. Uno che va in televisione a dire che il diritto internazionale conta fino a un certo punto. Uno che parla di “abordaggi pacifici”. Uno che sottolinea come i nostri concittadini non siano stati trattati da #Israele come terroristi. A parte il fatto che mente spudoratamente: da quanto emerge, le condizioni di detenzione sono state inaccettabili e, soprattutto, gli israeliani si sono accaniti sulle persone trattenute con azioni a dir poco intollerabili. Vale però la pena ricordare, ancora una volta, che i membri della #Flottilla non stavano commettendo alcuna azione illegale. Erano in acque internazionali (acque di tutti e di nessuno) e, soprattutto, del tutto disarmati. Per quanto ci riguarda, i nostri concittadini erano anche su imbarcazioni battenti bandiera italiana, dunque su territorio della Repubblica. La stessa Repubblica di cui, purtroppo (per quanto mi riguarda), #Tajani è ministro. Ora mi rivolgo a tutti, anche agli amici di destra. Gli attivisti possono anche esservi antipatici (personalmente non ho mai nutrito alcuna simpatia per #GretaThunberg), ma non comprendere che tenere la gente in carcere illegalmente, affamarla e assetarla, costringerla a baciare la bandiera israeliana in una cella infestata dalle cimici, sia semplicemente barbaro, vi rende peggiori di chi più vi ripugna. Sia chiaro. E qualcuno ha ancora il coraggio di parlare dell’unica democrazia del Medio Oriente? Ma con che faccia? #BattitoriLiberi: dal lunedì al venerdì alle 17, su Radio Cusano

Reuters: World

@reutersworldchannel · Post #149258 · 12.10.2021 г., 16:27

Thunberg expects 'meaningless' pledges at COP26 For activist Greta Thunberg, success at the upcoming U.N. climate conference would be possible if world leaders honestly admit that their action is not living up to their words. #GretaThunberg#COP26#UNClimateConference#ClimateChange#News#Reuters Subscribe: http://smarturl.it/reuterssubscribe Reuters brings you the latest business, finance and breaking news video from around the globe. Our reputation for accuracy and impartiality is unparalleled. Get the latest news on: http://reuters.com/ Follow Reuters on Facebook: https://www.facebook.com/Reuters Follow Reuters on Twitter: https://twitter.com/Reuters Follow Reuters on Instagram: https://www.instagram.com/reuters/?hl=en ➖@reutersworldchannel➖

Freedom Flotilla Coalition

@FFC_official_channel · Post #442 · 06.06.2025 г., 00:45

Macklemore endorses the Freedom Flotilla’s ‘Madleen’ on stage, playing a special video that Greta Thunberg recorded from the vessel. Keep all eyes on deck, and all eyes on Palestine. #GretaThunberg#Macklemore#BreakIsraelsSiege#EndTheBlockade#StandWithGaza#FreePalestine

Freedom Flotilla Coalition

@FFC_official_channel · Post #386 · 03.06.2025 г., 12:54

Listen to some of the Freedom Flotilla Coalition volunteers share why our nonviolent action is critical, just before they boarded the 'Madleen' in Catania. Keep track of our vessel and friends as they sail to Gaza via Marine Traffic or our website. Tag your Foreign Ministries to ensure that they safeguard the 'Madleen', and end their active participation in Israel's genocide and siege of Gaza. #BreakIsraelsSiege#EndTheBlockade#Madleen#FreedomFlotilla#HuwaidaArraf#GretaThunberg#DrMo#RimaHassan#YasmineAcar#ThiagoAvila