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

Резултати

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

Пребарај: #civilization

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

@interesting_planet_facts · Post #587 · 19.08.2025 г., 03:22

🌎 The Caral civilization in Peru built the oldest known city in the Americas around 2600 BCE. Its pyramid complexes predate the Inca by millennia and show early urban planning, trade, and communal gatherings long before written history in the region. ✨ #history⚡#archaeology⚡#civilization 👉subscribe Interesting Planet

Interesting Planet 🌍

@interesting_planet_facts · Post #874 · 07.10.2025 г., 20:11

🌎 The mysterious Harappan city of Dholavira, in India’s Gujarat region, features an intricate water management system with reservoirs, underground drains, and stone-lined wells. Archaeologists date the city from 3000 BCE to 1500 BCE and note its unique use of stepwells and multi-level reservoirs for collecting and distributing scarce water in the desert. ✨ #archaeology⚡#civilization⚡#mystery 👉subscribe Interesting Planet 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #410 · 24.10.2025 г., 12:31

🌍 The boundaries of ancient Mesopotamia shifted as rivers changed course, causing cities to move or vanish. River geography shaped the rise and fall of some of history’s earliest civilizations. ✨ #historicalgeography⚡#rivers⚡#civilization⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉more Channels ​

Interesting Planet 🌍

@interesting_planet_facts · Post #1121 · 11.12.2025 г., 22:11

🌎 Massive underground chambers beneath the ancient city of Derinkuyu in Turkey could shelter up to 20,000 people. This multi-level complex includes ventilation shafts, stables, kitchens, wells, and a school. Archaeologists believe it was carved from soft volcanic rock over 2,000 years ago to protect residents from invasions. ✨ #archaeology⚡#civilization⚡#Turkey 👉subscribe Interesting Planet 👉more Channels ​

Amazing Geography 🌍

@amazingeo · Post #678 · 31.03.2026 г., 20:31

🌍 The lost city of Cahokia once stood near present-day St. Louis, with earthen mounds and a population rivaling European cities around 1100 CE—making it North America’s largest urban center before Columbus. ✨ #historicalgeography⚡#archaeology⚡#civilization⚡#geography⚡#nature⚡#earth 👉subscribe Amazing Geography 👉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

Yukiokhruner

@yukiokhruner · Post #52 · 01.08.2022 г., 10:04

L'esigenza spontanea di uno spazio sacro sembra essere venuta meno nell'ultima forma della nostra civiltà #vaporonda#vaporwave#vapourwave#vaporart#seapunk#webpunk#glitch#glitchart#glitchartistscollective#chillwave#aesthetic#vaporwaveaesthetic#vaporwaveaesthetics#malinconia#melancholy#civiltà#civilization#egemonia#hegemony#sacro#sacred#suora#nun