TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #239 · 3 мај

Один из самых удобных способов записать данные это использование готовых форматов, такие как JSON или YAML. Из плюсов такого подхода стоит отметить вот что: 🔸 готовый, повсеместно используемый и поддерживаемый формат 🔸 простой и понятный файл, удобочитаемый для человека 🔸 можно легко редактировать в любом текстовом редакторе без специальных программ и библиотек Но есть и минусы 🔹 затраты времени при записи файла (кодирование данных в нужный формат строки) 🔹 затраты времени при чтении файла (декодирование данных в Python объекты) 🔹 размер файла увеличивается из-за разметки данных (скобки, запятые, переносы, отступы...) 🔹 перед записью все данные должны быть помещены в память в полном объёме (не всегда) 🔹 при чтении необходимо считать весь файл в память и только потом декодировать данные Если нужно писать немного данных в несколько файлов, то затраты по времени не ощутимы. Обычно это файлы конфига или какие-либо метаданные. Это отличный вариант под такие задачи. Есть и другой поход к записи файлов - это бинарные файлы. Используется, когда данных достаточно много и никто их не собирается читать глазками😳. 🔸 очень быстрая запись 🔸 чтение значительно быстрей чем JSON, YAML итд 🔸 размер файла значительно меньше, так как нет разметки 🔸 можно записывать данные по мере поступления не загружая всё в память 🔸 можно извлечь любую часть данных независимо Из минусов 🔹 нужно определить свой формат записи данных (если не используете готовую спецификацию определённого формата) 🔹 не получится открыть файл и визуально понять что там записано, а для чтения файла потребуется знать его спецификацию. 🔹 не так-то просто создать такой файл без специальной библиотеки В таком виде удобно записывать большой массив любых однородных данных. Например, мониторинг валютной биржи или кэшированная анимация 3D геометрии. (Это не означает что нельзя записать данные разного типа, просто это будет не так удобно) Представьте себе JPG-картинку. По сути это немного мета-информации и большой массив пикселей. Тоже самое со звуком или видео файлом. Поэтому, если вы попробуете открыть картинку в текстовом редакторе вы увидите что-то вроде такого f15d cd29 a564 4578 ... 09e2 9bc4 a696 1253 ... 84e9 4de1 3b23 c24a ... 2534 5161 28e0 709d ... ... Это и есть записанные байтики. И для их чтения требуется определённый софт который знает что с ними делать. Под каждый тип файла. К чему это я? Читайте в следующем посте... #tricks#basic

Резултати

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

Пребарај: #ppod

当前筛选 #ppod清除筛选
EverythingScience

@EverythingScience · Post #4991 · 11.12.2025 г., 21:06

#PPOD: Titan's Surface 🌕 The atmosphere of Titan, one of Saturn’s moons, appears similar to that on Earth about 3.5 billion years ago, before life appeared. After a seven-year journey on board the Cassini spacecraft, ESA’s Huygens probe reached Titan’s surface, marking the most distant landing ever achieved by a spacecraft. During the descent, its cameras collected data on the dense atmosphere and took the first-ever images of the surface. These revealed an extraordinary world with lakes, islands, and erosion features similar to those that shape our planet, confirming that liquid methane once flowed there. Methane on Titan is found in liquid form, not as a gas, due to the intense pressure and cold temperatures, about –180° C. Credit: esaNASA Source: @SETIInstitute @EverythingScience

Hashtags

EverythingScience

@EverythingScience · Post #4944 · 02.12.2025 г., 22:00

#PPOD: Deimos Before Sunrise 🌄 NASAPersevere captured this view of Deimos, the smaller of Mars' two moons, shining in the sky at 4:27 a.m. local time on March 1, 2025, the 1,433rd Martian day, or sol, of the mission. In the dark before dawn, the rover's left navigation camera used its maximum long-exposure time of 3.28 seconds to capture 16 individual shots, which were combined into a single image that was later sent to Earth. In total, the image represents an exposure time of about 52 seconds. The low light and long exposures add digital noise, making the image hazy. Many of the white specks seen in the sky are likely noise; some may be cosmic rays. Two of the brightest white specks are Regulus and Algieba, stars that are part of the constellation Leo. "Woodstock Crater," at center right, is roughly a half-mile (750 meters) away from the rover. At the time, Perseverance was en route to "Witch Hazel Hill." Credit: NASANASAJPLCaltech Source: @SETIInstitute @EverythingScience

Hashtags

EverythingScience

@EverythingScience · Post #4877 · 23.11.2025 г., 06:55

#PPOD: The Eye of the Crater 👁️ A vast cavity on the Red Planet looks back at ESA TGO with an icy stare. The crater is located in Utopia Planitia, the largest known impact basin in the Solar System, with a diameter of roughly 3,300 km, or twice the size of Earth’s Sahara Desert from north to south. This remnant of an ancient impact is just one of the many scars asteroids have inflicted upon the Red Planet. Water, volcanoes, and impacts from asteroids shaped the Martian surface in the ancient past. Mars is currently a cold, dry desert. This view from CaSSIS shows a crater approximately eight kilometres in diameter with material ejected in a manner that scientists believe suggests the presence of water ice. When the asteroid hit this region of Mars, the water ice melted, and a mix of liquid water and dust rock was propelled from the top layers. The smooth appearance of the crater is consistent with other features in the region, which have evidence of a water-ice history. Zooming into the crater, it is possible to see streaks on the walls of the crater, showing evidence of landslides, and ripples sculpted by the wind. Credit: ESA/ TGO/CaSSIS Source: @SETIInstitute @EverythingScience

Hashtags

EverythingScience

@EverythingScience · Post #4724 · 30.10.2025 г., 00:40

#PPOD: Mar­tian Win­ter Won­der­land ❄️ This sweeping view along a rusty red ridge and into a crater showcases the exquisite beauty of icy, layered terrain in the south polar region on Mars. The High Resolution Stereo Imaging camera onboard ESA’s Mars Express captured this frosty scene in the Ultimi Scopuli region near the south pole of Mars on 19 May 2022. At this time, it was southern hemisphere spring, and ice was starting to retreat. Dark dunes began to peak through the frost, and the elevated terrain appears ice-free. Credit: esaDLR enFU Berlin Source: @SETIInstitute @EverythingScience

Hashtags

EverythingScience

@EverythingScience · Post #5111 · 16.01.2026 г., 03:10

#PPOD: Neptune 🔵 NASAVoyager 2 made its closest approach to #Neptune in 1989, flying by 4,950 km above its cloud tops. It is still the only spacecraft to have visited the planet! The mission revealed 6 new moons, rings, and geysers erupting from the moon Triton. This Voyager 2 image of Neptune, processed by Kevin Gill, was captured on Aug. 31, 1989. Credit: NASANASAJPLCaltech / Kevin M. Gill Source: @SETIInstitute @EverythingScience

EverythingScience

@EverythingScience · Post #5078 · 06.01.2026 г., 19:10

#PPOD: Curiosity Sends Holiday Postcard from #Mars🌄 Team members working with NASA’s MarsCuriosity created this “postcard” by commanding the rover to take images at two times of day on Nov. 18, 2025, spanning the 4,722nd and 4,723rd Martian days, or sols, of the mission. The panoramas were captured at 4:15 p.m. on Sol 4,722 and 8:20 a.m. on Sol 4,723 (both at local Mars time), then merged together. Color was later added for an artistic interpretation of the scene, with blue representing the morning panorama and yellow representing the afternoon one. The resulting “postcard” is similar to ones the rover took in June 2023 and November 2021. Adding color to these kinds of merged images helps different details stand out in the landscape. Credit: NASANASAJPLCaltech Source: @SETIInstitute @EverythingScience

Hashtags