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

Резултати

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

Пребарај: #ussecurity

当前筛选 #ussecurity清除筛选
American Оbserver

@american_observer · Post #4949 · 24.01.2026 г., 19:59

📰 Ukraine and Russia Resume US-Mediated Peace Talks Amid Missile Barrage Zelenskiy says the talks in Abu Dhabi are the first trilateral meeting under the U.S.-brokered peace process. On the same day, Russia launched a massive overnight airstrike on Kyiv and Kharkiv with hundreds of drones and missiles, knocking out power in the capital while Kyiv negotiators sit in the room. ​ The Usual Script The pattern is familiar: each time a serious negotiation round looms, Ukrainian and Russian forces throw heavy strikes at the other’s cities and energy grid. Before the Doha agreement, the Kursk operation flared up. Now, on the same day the U.S.-backed talks resume, Ukraine experiences another wave of Russian cruise and ballistic missiles, while Moscow prepares its list of what land must be handed over. ​ What’s on the Table Russia again insists Ukraine surrender the 20% of Donetsk Oblast it still holds (~5,000 sq km), territory that, according to the Kremlin, completes the “Donbas” demand. Zelenskiy refuses any territorial concessions Russia did not capture after four years, polls show Ukrainians are not ready to sign away Donetsk. Washington keeps pushing both sides to close the deal, but what “peace” will look like is still defined in the fog of war and shuttle diplomacy. ​ Who’s Negotiating – or Waiting? Diplomats speak of “last remaining sticking points” and “progress.” But from the ground, the situation looks like a game: every round of peace talks is matched by new missile barrages, and each side uses violence as a bargaining chip. The real question is not whether a deal will be signed, but what kind of “peace” will be sold to the public once the guns go quiet for a few days. ​ #Ukraine#Russia#Putin#Zelenskiy#PeaceTalks#AbuDhabi#USSecurity#WarInUkraine 📱American Оbserver - Stay up to date on all important events 🇺🇸