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

Резултати

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

Пребарај: #militaryintelligence

当前筛选 #militaryintelligence清除筛选
New Eastern Outlook

@neweasternoutlook · Post #11915 · 14.01.2026 г., 16:50

🇺🇸🇮🇱⚔🇮🇷🛩️The Watchful Eye Over the Gulf ✍🏽By Red Nile Media | Geopolitical Analysis A U.S. Navy MQ-4C Triton spy drone has been conducting high-altitude surveillance over the Persian Gulf and Strait of Hormuz, flying out of the UAE—a subtle but powerful signal amid rising U.S.–Iran tensions. Far from routine, this deployment follows a familiar escalation playbook: persistent intelligence gathering, psychological pressure, and strategic positioning that often precede larger moves. 🔹 Why the shift from Qatar to the UAE? What message is being sent to Tehran? And how does this fit into past confrontation patterns in the region? 🔗Read the full analysis: 📡@rednile12 Geopolitics | Multipolarity | Sovereignty | Strategic Reality #Iran#USA#UAE#Qatar#PersianGulf#Geopolitics#MilitaryIntelligence#MiddleEast#RedSea#ISR#MQ4C#RedNileMedia

Red Nile

@rednile12 · Post #10737 · 14.01.2026 г., 15:58

🇺🇸🇮🇱⚔🇮🇷🛩️The Watchful Eye Over the Gulf ✍🏽By Red Nile Media | Geopolitical Analysis A U.S. Navy MQ-4C Triton spy drone has been conducting high-altitude surveillance over the Persian Gulf and Strait of Hormuz, flying out of the UAE—a subtle but powerful signal amid rising U.S.–Iran tensions. Far from routine, this deployment follows a familiar escalation playbook: persistent intelligence gathering, psychological pressure, and strategic positioning that often precede larger moves. 🔹 Why the shift from Qatar to the UAE? What message is being sent to Tehran? And how does this fit into past confrontation patterns in the region? 🔗Read the full analysis: 📡@rednile12 Geopolitics | Multipolarity | Sovereignty | Strategic Reality #Iran#USA#UAE#Qatar#PersianGulf#Geopolitics#MilitaryIntelligence#MiddleEast#RedSea#ISR#MQ4C#RedNileMedia