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

TGINSIGHT SIMILAR POSTS

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

Изворен канал @pythonotes · Post #22 · 19 јан.

Заметка начинающим, которые часто сталкиваются с подобной непоняткой. Ситуация следующая, есть список файлов: names = [ 'image.bmp', 'second.txt.bkp', 'data.db', '.config.cfg', 'file.ext.bkp' ] И мы хотим убрать у них окончание ".bkp". Не знаю зачем, пример довольно надуманный) Но суть он показывает, а это главное. Те, кто еще не очень знаком с библиотекой os.path или pathlib, вероятно решат обработать имена как строки. И тут вполне подойдет метод строки strip(). Что делает этот метод? Он отрезает указанные символы по обеим сторонам строки. Если ничего не указать, то убирает невидимые символы (пробелы, табуляции и переносы строк). В нашем случае будет выглядеть вот так: >>> name.strip('.bkp') То есть просим удалить строку '.bkp' по краям имени файла, если таковая есть. Можно применить аналогичный метод rstrip(), чтобы отрезать только справа, но для этого примера используем обычный. >>> for name in names: >>> print(name.strip('.bkp')) image.bm second.txt data.d config.cfg file.ext Хм, что-то не то с нашими именами! Что случилось??? Видим нежелательное переименование в именах, где и близко не было указанной строки '.bkp' А дело всё в том, что данный метод ищет не указанную строку, а указанные символы, и не важно в каком порядке. Для метода strip() строка '.bkp' это не паттерн для поискаа список символов. Потому он отрезал симовол 'p' от '.bmp' и удалил точку из файла '.config.cfg'. Как тогда правильно заменить именно паттерн? Для начинающего можно посоветовать метод строки replace(), который как раз использует для замены указанную строку целиком. В нашем примере заменим её на пустую строку. >>> for name in names: >>> print(name.replace('.bkp', '')) image.bmp second.txt data.db .config.cfg file.ext Уже лучше, но помните, это лишь пример про strip(). Для работы с именами файлов есть способы и более "правильные", дающие однозначно верный результат. Я взял файлы только в качестве примера. Даже replase() тут может сделать не то что ожидаем. Просто впредь будьте внимательны с этим strip(). #basic

Hashtags

Резултати

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

Пребарај: #paleoclimate

当前筛选 #paleoclimate清除筛选
Interesting Planet 🌍

@interesting_planet_facts · Post #1175 · 30.12.2025 г., 12:11

🌎 Layers of ancient lake and ocean sediments serve as natural records of Earth's climate. By studying pollen, ash, and chemical changes in these sediments, scientists can reconstruct temperature, rainfall, and ecosystem shifts from thousands to millions of years ago. Some Greenland and Antarctic cores show detailed yearly changes stretching back over 100,000 years. ✨ #geology⚡#climate⚡#paleoclimate 👉subscribe Interesting Planet 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #253 · 17.09.2025 г., 13:12

🌍 The Sahara was once a lush region covered with lakes and grasslands about 10,000 years ago. Ancient rock art and fossils show hippos and crocodiles lived where desert sands now stretch for miles. ✨ #historicalgeography⚡#paleoclimate⚡#sahara⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍 ​

Interesting Planet 🌍

@interesting_planet_facts · Post #653 · 29.08.2025 г., 20:22

🌎 Layers of ancient coral reefs act as natural records of Earth’s climate history. By analyzing their growth bands, scientists uncover patterns of sea temperature and ocean chemistry stretching back millions of years. ✨ #coral⚡#geology⚡#paleoclimate 👉subscribe Interesting Planet ​

Interesting Planet 🌍

@interesting_planet_facts · Post #876 · 08.10.2025 г., 12:11

🌎 Ancient lake beds called "playa lakes" preserve natural records of Earth's past. Layers of sediment in these basins capture pollen, plant remains, and even insect fossils, revealing climate cycles and environmental shifts over thousands of years. Some dry lakebeds in the U.S. Southwest show records going back 120,000 years. ✨ #geology⚡#paleoclimate⚡#lakes 👉subscribe Interesting Planet 👉more Channels ​

Interesting Planet 🌍

@interesting_planet_facts · Post #714 · 09.09.2025 г., 00:22

🌎 Mud layers at the bottom of lakes and oceans provide detailed natural records of Earth's past climates. These sediments contain pollen, fossils, and chemical traces, letting scientists reconstruct environmental changes over hundreds of thousands of years. ✨ #paleoclimate⚡#sediments⚡#geology 👉subscribe Interesting Planet ​

Interesting Planet 🌍

@interesting_planet_facts · Post #1070 · 25.11.2025 г., 12:11

🌎 Beneath the waters of the Bahamas, the so-called “blue holes” are deep, vertical underwater caves formed during past ice ages when sea levels were lower. Some exceed 300 meters in depth and preserve ancient fossils and climate records in their oxygen-poor layers. ✨ #ocean⚡#cave⚡#paleoclimate 👉subscribe Interesting Planet 👉more Channels ​

Interesting Planet 🌍

@interesting_planet_facts · Post #1229 · 16.01.2026 г., 22:11

🌎 Around 252 million years ago, the Permian-Triassic extinction wiped out about 90% of marine species and 70% of land vertebrates. Massive volcanic eruptions in Siberia released greenhouse gases that drove rapid global warming, ocean acidification, and low oxygen levels—making it the largest extinction event in Earth's history. ✨ #extinction⚡#volcanoes⚡#paleoclimate 👉subscribe Interesting Planet 👉more Channels ​

Interesting Planet 🌍

@interesting_planet_facts · Post #1307 · 21.02.2026 г., 12:11

🌎 Antarctic ice cores act as natural records of Earth's atmosphere, trapping ancient air bubbles that show CO2, methane, and temperature changes going back 800,000 years. ✨ #icecores⚡#paleoclimate⚡#antarctica 👉subscribe Interesting Planet 👉more Channels ​

Interesting Planet 🌍

@interesting_planet_facts · Post #1208 · 09.01.2026 г., 22:11

🌎 Antarctica’s ancient ice sheets hold Earth’s longest direct climate records. Deep ice cores reveal trapped air bubbles, preserving atmospheric changes over 800,000 years. This helps scientists track greenhouse gas levels and temperature shifts across multiple ice ages. ✨ #Antarctica⚡#icecores⚡#paleoclimate 👉subscribe Interesting Planet 👉more Channels ​

Interesting Planet 🌍

@interesting_planet_facts · Post #909 · 14.10.2025 г., 20:11

🌎 Ice cores drilled from Antarctica and Greenland are frozen time capsules, preserving thousands of years of air bubbles, pollen, and tiny particles. By analyzing these layers, scientists reconstruct past temperatures, volcanic eruptions, and atmospheric changes stretching back over 800,000 years. ✨ #icecores⚡#paleoclimate⚡#atmosphere 👉subscribe Interesting Planet 👉more Channels ​

Environment & Climate Change

@Enviro_Climate · Post #372 · 18.09.2021 г., 13:21

Sea Secrets - Arash Sharifi Arash Sharifi, a Ph.D. candidate of marine geology and geophysics at the UM Rosenstiel School, takes us into the compelling world of #paleoclimate research. By using climate, #historical, and #archeological records, Sharifi shows how climate change has been affecting the world since the beginning of human #civilization. @Enviro_Climate https://youtu.be/ovy-57jx85Q?t=3

Interesting Planet 🌍

@interesting_planet_facts · Post #1089 · 01.12.2025 г., 12:11

🌎 Coral reefs provide another remarkable natural record of Earth’s past. As corals grow, they form bands in their skeletons that reflect seasonal changes in water temperature, chemistry, and even extreme weather events. Some coral cores reveal ocean conditions dating back several centuries. ✨ #coral⚡#reefs⚡#paleoclimate⚡#oceanography 👉subscribe Interesting Planet 👉more Channels ​