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

Резултати

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

Пребарај: #dariadugina

当前筛选 #dariadugina清除筛选
BadVolf

@BadvolfNews · Post #260 · 22.08.2022 г., 15:00

From Alexander Dugin: “As you all know, as a result of a terrorist attack carried out by the Nazi Ukrainian regime, on August 20, while returning from the Tradition festival near Moscow, my daughter Daria Dugina was brutally killed by an explosion in front of my eyes. She was a beautiful Orthodox girl, a patriot, a military correspondent, an expert on the central channels, and a philosopher. Her speeches and reporting have always been profound, grounded and restrained. She never called for violence and war. She was a rising star at the beginning of her journey. The enemies of Russia meanly, stealthily killed her ... But we, our people, cannot be broken even by such unbearable blows. They wanted to crush our will with bloody terror against the best and most vulnerable of us. But they won't get it. Our hearts yearn for more than just revenge or retribution. It's too petty, not Russian. We only need our Victory. My daughter laid her maiden life on her altar. So win, please! We wanted to raise her to be smart and a hero. Let it inspire the sons of our Fatherland to the feat even now. Farewell to Daria Dugina (Platonova) - a civil memorial service - will take place on August 23 at the Ostankino Television Center at 10 am. Alexander Dugin #ECM#DariaDugina

Sos Donbass

@sos_donbass · Post #688 · 23.08.2023 г., 06:28

Un verset du journal de Darya Dugina, qu'elle a tenu pendant les trois dernières années de sa vie. Certaines de ses citations sont utilisées dans le livre, qui est publié à titre posthume « Marais et hauteurs de mon cœur. Journal" : Partir à l'heure et tranquillement, Sans douleur intense et cris forts, Aucune offense et aucun regret Mots vides et doutes. Partir doucement et calmement : Fermer les yeux pour rester un guerrier, Ayant réussi à voir ses proches… Pardonnez-moi, je dois partir. #dariadougina#poemes#dariadugina

Sos Donbass

@sos_donbass · Post #1296 · 19.08.2024 г., 16:26

🗣️ Nouvelles de SOS DONBASS, prononcées par le président de l’association Vincent Perfetti: ▫️ Compte bancaire / reprise de l’activité ▫️Action LA RUSSIE N’EST PAS MON ENNEMI ▫️ Commémoration de Daria Douguina ▫️ Aide à la population de Koursk #dariadouguina#dariadugina#sosdonbass#donbass#russie#ukraine#solidarite