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

Резултати

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

Пребарај: #2026amnestylaw

当前筛选 #2026amnestylaw清除筛选
Venezuelanalysis

@venanalysis · Post #2282 · 23.02.2026 г., 14:10

📰 NEWS | Venezuelan Parliament Approves Amnesty Law, Rodríguez Calls for ‘Peace and Tolerance’ Venezuela’s National Assembly has passed the Amnesty Law for Democratic Coexistence, establishing a blanket amnesty for crimes committed in the context of political violence between 1999 and 2026. The legislation references events including the 2002 coup attempt, the 2014 and 2017 protests, and unrest following the July 2024 presidential elections. Article 7 excludes serious human rights violations, crimes against humanity, war crimes, homicide, corruption offenses in public office, and drug trafficking with sentences exceeding nine years. Parliament created a Special Monitoring Commission to oversee implementation. According to its president, 379 amnesty requests have been processed, with further cases under revision. Read our full report here 👉🏾https://venezuelanalysis.com/news/venezuelan-parliament-approves-amnesty-law-rodriguez-calls-for-peace-and-tolerance/ #2026AmnestyLaw#Opposition

Venezuelanalysis

@venanalysis · Post #2273 · 10.02.2026 г., 14:08

📰 NEWS | Venezuelan Authorities Begin Consultations on Amnesty Law The Venezuelan National Assembly has begun nationwide consultations on a preliminarily approved “Amnesty Bill for Democratic Coexistence,” holding meetings with community peace judges, civil society organizations and university law faculties. Lawmakers said the process aims to gather input before a revised version is submitted for a final vote in the coming weeks. The bill seeks to pardon political and related crimes committed between January 1, 1999, and January 30, 2026, while explicitly excluding serious human rights violations, crimes against humanity, homicide, drug trafficking and corruption. Former Spanish President José Luis Rodríguez Zapatero endorsed the initiative during a meeting in Caracas, describing it as a turning point for national reconciliation. Read the full report here 👉https://venezuelanalysis.com/news/venezuelan-authorities-begin-consultations-on-amnesty-law/ #2026AmnestyLaw#Opposition

Venezuelanalysis

@venanalysis · Post #2286 · 28.02.2026 г., 00:00

📰 NEWS | Venezuela: Attorney General and Ombudsman Resign as Authorities Process Thousands of Amnesty Requests National Assembly President Jorge Rodríguez confirmed the resignations of Attorney General Tarek William Saab and Ombudsman Alfredo Ruiz. Parliament declared urgency, formed a 13-member committee to appoint new officials within 30 days, and named interim replacements. The developments come as authorities process Amnesty Law requests covering cases dating back to 1999. Deputy Jorge Arreaza reported 8,110 petitions filed since approval last week, with 4,757 individuals benefiting so far, including 223 released from prison and 4,534 cleared of parole-type measures. Read our full report here: https://venezuelanalysis.com/news/venezuela-attorney-general-and-ombudsman-resign-as-authorities-process-thousands-of-amnesty-requests/ #2026AmnestyLaw#NationalAssembly#TarekWilliamSaab