@bestwallpapes · Post #3064 · 22.11.2024 г., 05:30
@Bestwallpapes #Cosmic#Desktop
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
Пребарај: #cosmic
@bestwallpapes · Post #3064 · 22.11.2024 г., 05:30
@Bestwallpapes #Cosmic#Desktop
@bestwallpapes · Post #3632 · 30.08.2025 г., 17:28
@Bestwallpapes #Cosmic#Stars
@bestwallpapes · Post #3161 · 17.12.2024 г., 09:13
@Bestwallpapes #Sky#Stars#Cosmic
@spaceuniverses · Post #146 · 26.02.2022 г., 07:00
🌟Planetary nebulas are expanding shells of gas produced by a dying #star as it sheds its outer layers. These jettisoned shells remain for a relatively short time in #cosmic terms — tens of thousands of years — before gradually dissipating into #space. Planetary nebula NGC 7027 is located about 2,900 light years from Earth.
@SukoFaultyArtLair · Post #4961 · 03.02.2020 г., 13:30
https://www.furaffinity.net/view/34865821/ #female#cosmic#star#starlane#pinup
@cosmomyst · Post #415 · 12.10.2025 г., 22:21
🪐 On August 27, 1998, astronomers detected a remarkable gamma-ray burst from the magnetar SGR 1900+14, located about 20,000 light-years away in the constellation Aquila. This event released more than a thousand times the energy of the Sun in just a fraction of a second, making it one of the brightest gamma-ray flashes ever recorded and proving that magnetars—neutron stars with ultra-strong magnetic fields—can unleash explosions powerful enough to briefly outshine entire galaxies. ✨ #gamma-ray-bursts ⚡#magnetar⚡#cosmic-explosions ⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries 👉more Channels
@kejiqu · Post #4250 · 10.03.2026 г., 03:06
宇宙是无限的吗? 观测数据显示宇宙呈现平坦状态,但其真实大小和超出可观测范围的整体形状可能永远无法确定。科学家指出,如同地球表面具有可测量的尺寸,如果地球膨胀,其尺寸会随时间增加。然而,宇宙的真实性质,包括其是否无限,以及超出可观测范围的形状,仍然是未解之谜。目前的技术手段无法确定宇宙的全局几何结构,其真实尺寸和形状可能永远无法被人类完全认知。SciTechDaily 🏷#Universe#Cosmic#Geometry#Observations 📢频道👥群组📝投稿
@cosmomyst · Post #502 · 16.11.2025 г., 22:21
🪐 In 2021, astronomers detected a record-breaking gamma-ray burst called GRB 211211A, which defied expectations by lasting over a minute—much longer than most "short" bursts thought to arise from merging neutron stars. Observations with space telescopes revealed this unusually long burst likely came from the merger of two neutron stars in a distant galaxy, showing that cosmic collisions can create gamma-ray explosions with a wider variety of durations and energies than previously believed. ✨ #gamma-ray-bursts ⚡#neutron-stars ⚡#cosmic-explosions ⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries 👉more Channels
@cosmomyst · Post #365 · 02.10.2025 г., 22:21
🪐 In December 2004, the galaxy NGC 1637 in the constellation Eridanus was the source of a rare and powerful cosmic event known as a "short gamma-ray burst." Lasting less than two seconds, these bursts are believed to result from the merger of two neutron stars—ultra-dense remnants of massive stars—which create a flash of high-energy gamma rays strong enough to briefly outshine entire galaxies before fading away in moments. ✨ #gamma-rays ⚡#neutron-stars ⚡#cosmic-explosions ⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries 👉more Channels
@cosmomyst · Post #645 · 28.01.2026 г., 12:21
🪐 The dwarf galaxy GRB Host 080605, located nearly 6.5 billion light-years away, is home to one of the brightest long-duration gamma-ray bursts ever detected. This powerful explosion, which lasted over a minute, released more energy than our Sun will emit in its entire lifetime, making GRB 080605 a textbook example of how collapsing massive stars can light up distant galaxies with blinding bursts of high-energy light. ✨ #gamma-ray-bursts ⚡#distant-galaxies ⚡#cosmic-explosions ⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries 👉more Channels
@cosmomyst · Post #391 · 08.10.2025 г., 12:21
🪐 When a massive star dies in a distant galaxy, it can create a stunning cosmic explosion called a gamma-ray burst, or GRB—an event so powerful that it outshines entire galaxies for a few seconds. In 2021, the galaxy GN-z11, over 13.4 billion light-years away, was revealed as the host of one of the earliest gamma-ray bursts ever detected, showing that even in the universe's first few hundred million years, these immense blasts were shaping the cosmos. ✨ #gamma-ray-bursts ⚡#GN-z11 ⚡#cosmic-explosions ⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries 👉more Channels
@AloneSnowflake · Post #342 · 02.04.2024 г., 21:31
⊹ 𝐀pply 𝐓heme ˓ ✨ ˒ ༄ 𝐉oin 𝐂hannel ˙˚• #Galaxy#Galactic#Moon#Dark#Geometric#Minimal#Black#Cosmos#Cosmic#Theme