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

Резултати

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

Пребарај: #letthemsail

当前筛选 #letthemsail清除筛选
Freedom Flotilla Coalition

@FFC_official_channel · Post #225 · 04.09.2024 г., 20:53

BREAKING ⚠️🚨 ⛴️⛴️⛴️ After months of failed negotiations, the @gazafreedomflotilla campaign in Turkiye @mavimarmaratr started the #FreedomWatch , a non-violent direct action with hundreds of people to free our boats from Hyadarpasa port in Istambul. The demonstrators blocked the port entrance and peacefully chained themselves to the gates. 🚨 LIVE NOW: https://www.instagram.com/mavimarmaratr?igsh=emNib2ZtZHFjZTFj 🇵🇸🍉 The objective of this inspiring action is that the we can finally sail to #Gaza to take desperately needed humanitarian aid and break the genocidal siege that Israel established on Gaza since 2007. ⛴️ Our protests in Turkiye will continue until our boats are free to sail, since they have all the necessary documentation and meet all the necessary requirements to do so. Please help us share this important action to #BreakTheSiege and to create a people´s humanitarian corridor in Gaza. When governments fail, we sail! #FreedomFlotilla#WeWillSail#LetThemSail🇵🇸

Freedom Flotilla Coalition

@FFC_official_channel · Post #121 · 25.05.2024 г., 19:52

After prolonged negotiations with the Dutch Port Authority, ‘Handala’ is finally docked in Rotterdam! The Freedom Flotilla Coalition had organized a place to dock with Rotterdan City Marina but for undisclosed reasons, were prevented from docking in the planned location. This delay impacted our peaceful event and demonstration to welcome ‘Handala’ where children had drawn pictures and letters of support to send to Palestinian people in Gaza. John Turnbull, representative of Canada Boat to Gaza, said “while engaging on this mission, the Palestinians are teaching us how to resist”. Handala will continue to challenge the complicity of European countries on a journey to break the siege of Gaza. Next stop, London! #breakthesiege#endtheblockade#gaza#palestine#freegaza#freepalestine#weaillsail#letthemsail#handala

Freedom Flotilla Coalition

@FFC_official_channel · Post #197 · 25.07.2024 г., 07:59

Robert has long fought alongside Palestinians and isn't stopping now. Having spent time in Palestine documenting horrific human rights abuses by Israeli forces, he has seen the brutality of the occupation first hand. Despite the extreme difficulty in leaving his children and partner back home in what he describes as a "grieving process", he shares how important it is to use his privilege to be a part of the collective effort to break the siege on Gaza. As we have witnessed over the course of 9 months and 76+ years prior, we cannot fathom or predict the IOF's brutality or what they are capable of if they intercept 'Handala' in international waters. So we need your help in keeping Robert as safe as possible. We need your help in demanding safe passage for all volunteers onboard our Flotillas. Please share our videos, tag your politicians and ensure that we reach Gaza safely. #endtheblockade#breakthesiege#robertmartin#freepalestine#freegaza#endtheoccupation#solidarity#wewillsail#letthemsail

Freedom Flotilla Coalition

@FFC_official_channel · Post #102 · 12.05.2024 г., 07:10

Palestinians in Gaza are being forced to endure a “vicious cycle of malnutrition, infection, wounds breaking down, more infection, more malnutrition”, explains British surgeon haunted by Gaza horrors. Professor Nick Maynard has only just arrived back in the UK after lending his expertise in Gaza where he witnessed teenagers with treatable, survivable injuries, whose bodies tragically shut down due to malnutrition. We need to break the siege of Gaza. We need to ensure the borders are opened to be able to provide medical aid and food to these teenagers and their families immediately. This could not be more urgent. #BreakTheSiege#AllEyesOnRafah#EndTheBlockade#GazaBlockade#FreedomFlotilla#WeWillSail#LetThemSail#Rafah#NickMaynard

Freedom Flotilla Coalition

@FFC_official_channel · Post #226 · 06.09.2024 г., 04:19

The demonstration to release our Flotilla ships currently being prevented from leaving port by the Turkish Port Authorities, continues in Istanbul. We need your help in getting international media to cover this historic protest and help put pressure on the government to release our ships, ensuring we can sail towards Gaza. HOW TO HELP: 1. Call, email and/or demonstrate at Turkish embassies and consulates and demand that the Freedom Flotilla ships be released and allowed to deliver aid to Gaza immediately. 2. Tag mainstream accounts in this post or when you share our photos to your stories. 3. Message the social media page of the Ministry of Transport and Foreign Affairs @tcdisisleri and @uabakanligi on IG and on X 4. Share our videos using the hashtags #WeWillSail and #LetThemSail tagging @tcdisisleri and @uabakanligi #WeWillSail#LetThemSail#TheFreedomFlotilla#FFC#Istanbul#Turkiye#Turkey#MaviMarmara