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

TGINSIGHT SIMILAR POSTS

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

Изворен канал @pythonotes · Post #191 · 14 дек.

Как разделить строку с shell-командой на отдельные аргументы в виде списка? Если сделать просто сплит по пробелу то получим то что надо, кроме случаев со вставками текста с пробелами. Например так: >>> '-arg "I Am Groot"'.split(' ') ['-arg', '"I', 'Am', 'Groot"'] Чтобы учитывать текст в кавычках как единый аргумент можно воспользоваться функцией shlex.split() Кто читает мой канал давно, уже в курсе. А что делать, если нужно обратное действие? Объединить аргументы из списка в строку и при этом добавить кавычки в аргумент с пробелами. Конечно, если вы используете subprocess то он сам всё разрулит. Но если вам нужна именно команда одной строкой, то можно воспользоваться готовой функцией в том же subprocess. >>> from subprocess import list2cmdline >>> list2cmdline(['-arg', 'I Am Groot']) '-arg "I Am Groot"' Он также позаботится об экранировании уже имеющихся кавычек >>> list2cmdline(['-arg', 'I Am "Groot"']) '-arg "I Am \"Groot\""' А вот так он может "схлопнуть" в команду JSON >>> list2cmdline(['--json', json.dumps({'key': 'value'})]) '--json "{\"key\": \"value\"}"' _______________ Возможно кто-то спросит, а зачем соединять аргументы в строку если subprocess сам это сделает а os.system не наш путь? Мне как-то потребовалось отправлять команду на удалённое выполнение и в API поддерживалось указание команды только строкой. Так что всякое бывает) #libs#basic

Hashtags

Резултати

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

Пребарај: #himalayas

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

@interesting_planet_facts · Post #437 · 27.07.2025 г., 14:22

🌎 In the Himalayas, the snow leopard’s wide, fur-covered paws act like natural snowshoes, distributing weight and keeping it from sinking on deep mountain snow. ✨ #wildlife⚡#adaptation⚡#Himalayas 👉subscribe Interesting Planet

Interesting Planet 🌍

@interesting_planet_facts · Post #596 · 20.08.2025 г., 18:22

🌎 The larva of the Himalayan glacier midge survives temperatures as low as -17°C by producing special proteins that act like antifreeze, preventing ice crystals from damaging its tissues. This adaptation lets it thrive in some of the coldest, highest places on Earth. ✨ #insects⚡#adaptation⚡#Himalayas 👉subscribe Interesting Planet

Amazing Geography 🌍

@amazingeo · Post #194 · 07.09.2025 г., 16:12

🌍 The Himalayas are rising by about 5 millimeters each year as the Indian and Eurasian plates continue to collide. This ongoing uplift makes these mountains among the youngest and fastest-growing on Earth. ✨ #mountains⚡#Himalayas⚡#tectonics⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography🌍 ​

Interesting Planet 🌍

@interesting_planet_facts · Post #1185 · 02.01.2026 г., 18:11

🌎 Bar-headed geese cross the Himalayas during migration, flying at altitudes above 7,000 meters. These birds have special hemoglobin that helps them absorb oxygen efficiently in thin air. Their migration route includes nonstop flights of up to 1,600 kilometers. ✨ #migration⚡#birds⚡#Himalayas 👉subscribe Interesting Planet 👉more Channels ​

Interesting Planet 🌍

@interesting_planet_facts · Post #474 · 31.07.2025 г., 16:22

🌎 In the soaring skies of the Himalayas, the bar-headed goose migrates over Mount Everest, flying at altitudes above 8,000 meters—higher than any other bird. Special hemoglobin in their blood enables them to absorb oxygen efficiently in the thin air, making this epic journey possible each year. ✨ #migration⚡#birds⚡#Himalayas 👉subscribe Interesting Planet

Interesting Planet 🌍

@interesting_planet_facts · Post #1260 · 29.01.2026 г., 12:11

🌎 Mount Everest's border runs exactly along the Nepal-China divide, making its summit shared by two countries. Hikers can reach the top from either side, but the official border marker is a small metal pole embedded in the ice at 8,848 meters—the highest international boundary on Earth. ✨ #borders⚡#geography⚡#Himalayas 👉subscribe Interesting Planet 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #590 · 24.01.2026 г., 12:31

🌍 The Eastern Himalayas are a biodiversity hotspot with over 10,000 plant species, and nearly a quarter of them are found nowhere else, despite covering less than 2% of India’s total area. ✨ #biodiversity⚡#Himalayas⚡#ecology⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #441 · 08.11.2025 г., 12:31

🌍 The Kalapani region is a small Himalayan area claimed by both India and Nepal. Its strategic location at the tri-junction with China makes it a unique hotspot of geopolitical geography. ✨ #borders⚡#dispute⚡#Himalayas⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Interesting Planet 🌍

@interesting_planet_facts · Post #386 · 22.07.2025 г., 16:22

🌎 High in the Himalayan valleys, the Himalayan blue poppy blooms with dazzling blue petals. Its color comes from unique pigments that protect it from intense ultraviolet sunlight found at high altitudes. ✨ #flowers⚡#adaptation⚡#Himalayas 👉subscribe Interesting Planet

Amazing Geography 🌍

@amazingeo · Post #606 · 01.02.2026 г., 12:31

🌍 In Himalayan valleys, local communities have revived ancient glacial water channels called "kuls" to guide meltwater for farming. These living systems adapt to changing ice and rainfall each year. ✨ #Himalayas⚡#adaptation⚡#irrigation⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Interesting Planet 🌍

@interesting_planet_facts · Post #503 · 05.08.2025 г., 13:22

🌎 The Himalayan honey bee builds its hives on high cliffs, crafting giant honeycombs and producing reddish honey with unique psychoactive properties prized by local tribes. ✨ #honeybee⚡#Himalayas⚡#nature 👉subscribe Interesting Planet

Interesting Planet 🌍

@interesting_planet_facts · Post #451 · 28.07.2025 г., 20:22

🌎 Some Himalayan glaciers are “surge glaciers,” moving up to 100 times faster than normal for short periods. These icy rivers can suddenly speed up, advancing kilometers in months instead of centuries—reshaping valleys with astonishing power. ✨ #glacier⚡#Himalayas⚡#earth 👉subscribe Interesting Planet