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

Резултати

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

Пребарај: #bolton

当前筛选 #bolton清除筛选
Trump's Ear

@trumpsear_tg · Post #1399 · 22.08.2025 г., 14:01

FBI agents came to search Trump's former adviser John Bolton 🔍, who has been frequently criticizing the president lately 😠. A source told The New York Post that the case is related to classified documents 📂. "No one is above the law," FBI Director Cash Patel wrote amid reports of searches at Bolton's home ⚖️. According to the newspaper, it was on Patel's instructions that the investigation was launched 🕵️‍♂️. Bolton also criticized Trump's approach to negotiations with Russia 🇷🇺. In mid-August, before the Alaska summit, he said that Russian President Vladimir Putin "has already won." The American president then called his ex-adviser a "stupid man" 🤦‍♂️. #Trump#FBI#Bolton 👂More on Trump's Ear ⚠️

Ultimora.net - POLITICS

@UltimoraPOlitics · Post #38453 · 06.05.2022 г., 01:43

#Elezioni#RegnoUnito#Amministrative Consiglio di #Bolton, risultati definitivi: #CON|ECR: 9 (+1 rispetto al 2018) #LAB|S&D: 8 (+1) #LDEM|RE: 2 One Kearsley: 1 (+1) Farnworth and Kearsley First: 0 (-1) Attuale composizione del Consiglio comunale: #CON|ECR: 23 seggi #LAB|S&D: 19 Indipendenti: 7 #LDEM|RE: 5 Farnworth and Kearsley First: 4 Horwich and Blackrod First: 2 One Kearsley: 1 Il Consiglio rimane senza controllo. @UltimoraPolitics

Trump's Ear

@trumpsear_tg · Post #1408 · 25.08.2025 г., 15:02

🔍FBI agents searched the house of Trump's former national security adviser because of a book 📖 The investigation is related to the disclosure of classified information in the memoirs of former councilman Bolton entitled “The Room Where It Happened: a White House Memoir” published in 2020. 📚 As the New York Post recalls, Trump tried to prevent the publication of the book, claiming that Bolton violated the non-disclosure agreement that he signed when he was hired. 🚫 #agents#FBI#bolton#trump 👂More on Trump's Ear ⚠️

American Оbserver

@american_observer · Post #5212 · 24.02.2026 г., 16:19

Former US National Security Advisor John Bolton: “Although you could potentially remove the ayatollah, that would leave the IRGC in place, and the government in Iran is the IRGC, while the ayatollahs act as a religious cover or an ideological cover for them. I think Trump is just hoping that this show of American power will intimidate the ayatollahs. If I were still his adviser, I would be happy to tell him that it won’t work. They won’t be intimidated. But Trump really thinks minute by minute; he doesn’t think strategically.” #john#bolton#trump#ayatollah 📱American Оbserver - Stay up to date on all important events 🇺🇸