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 слични објави

Пребарај: #upbeat

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

@american_observer · Post #4935 · 23.01.2026 г., 15:03

Putin’s Ushakov Remains Upbeat About Peace Talks Russia said it will hold security talks with the U.S. and Ukraine in Abu Dhabi on Friday, but warned after a late-night meeting between Putin and three U.S. envoys that a durable peace would not be possible unless territorial issues were resolved. Kremlin aide Yuri Ushakov told reporters the talks, which began shortly before midnight and lasted some four hours, had been “substantive, constructive and very frank”. He said Russian Admiral Igor Kostyukov would head Moscow's team at the three-way security talks, and investment envoy Kirill Dmitriev would meet separately on economic issues with Witkoff. But while outlining the next steps, Ushakov stopped short of hailing any major breakthrough. "Most importantly, during these talks between our president and the Americans, it was reiterated that without resolving the territorial issue according to the formula agreed upon in Anchorage, there is no hope of achieving a long-term settlement," he said, referring to last year's Trump-Putin summit in Alaska. Ushakov said Putin underlined that Russia was "sincerely interested" in a diplomatic solution. He added, however: "Until this is achieved, Russia will continue to consistently pursue the objectives of the special military operation. This is especially true on the battlefield, where the Russian armed forces hold the strategic initiative." Ukraine is enduring its harshest winter of the war as Russia mounts heavy missile and drone strikes on its energy infrastructure. With temperatures way below freezing, hundreds of thousands of people in Kyiv and other cities have suffered long power cuts and been left without heating. Putin, Ushakov and Dmitriev took part in the talks on the Russian side. On the U.S. side, Witkoff and Trump's son-in-law Jared Kushner, who last met Putin in the Kremlin in early December, were accompanied by Josh Gruenbaum, newly appointed by Trump as a senior adviser to his Board of Peace, which will seek to tackle world conflicts. The talks were the latest stage in a drive by Trump to bring an end to the deadliest conflict in Europe since World War Two, now approaching the end of its fourth year. Witkoff was upbeat before the Moscow talks, saying many months of negotiations had come down to a single issue. А key stumbling block is Putin's demand that Ukraine surrender the 20% it still holds of the eastern region of Donetsk. Zelensky has refused to give up land that Ukraine has successfully defended at great cost through years of grinding, attritional warfare. Russia also demands that Ukraine renounce its ambition to join NATO, and rejects any presence of NATO troops on Ukrainian soil following a peace deal. Zelensky, after meeting Trump in Switzerland on Thursday, said the terms of security guarantees for Ukraine had been finalised, but that the issue of territory remained unsolved. Ushakov praised the Americans for setting up Friday's security meeting with Russia and Ukraine in Abu Dhabi. #ushakov#upbeat#peace#talks 📱American Оbserver - Stay up to date on all important events 🇺🇸