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

Пребарај: #uncertainty

当前筛选 #uncertainty清除筛选
IELTS|Newspapers & Magazines|English

@emagzinewspars · Post #9736 · 18.12.2025 г., 15:35

#MIT_Sloan_Management_Review🇺🇸📕[PDF]⬇️ #Winter2026 #Monthly_Magazines For learning, for free(dom). @backupofmagazines This issue explores how leaders can turn volatility into advantage by treating #Uncertainty not as a threat but as a strategic resource. The issue’s cover package on #StrategicForesight shows how scenario planning, analogical thinking, and long-term perspective help organizations navigate an #AI-driven world. Essays on #AuthenticLeadership question whether “being yourself” builds trust or excuses bad behavior, while deep dives into #AlgorithmicPricing and #ResponsibleAI highlight rising legal and ethical risks. Across strategy, innovation, and #Sustainability, the message is clear: progress comes from disciplined adaptation, not endless upheaval.

Crypto M - Crypto News

@CryptoM · Post #65043 · 10.04.2026 г., 15:45

🚀 U.S. Prepares Military Response Amid Iran Peace Talks, Says Trump U.S. President Donald Trump has stated that if peace negotiations with Iran fail, American warships are being equipped with advanced ammunition to resume strikes. According to Odaily, Trump's comments came shortly before U.S. Vice President Vance boarded Air Force Two en route to Islamabad for peace talks with Witkoff and Kushner. In a phone interview, Trump expressed uncertainty about the success of the negotiations, saying, "We will know in about 24 hours. We are rearming our ships with the finest ammunition and the most advanced weapons, even better than what we used before, which had already defeated them. If no agreement is reached, we will use them very effectively." Trump further commented on the unpredictability of the situation, stating, "We are dealing with people whose honesty is uncertain. They claim to abandon all nuclear weapons in front of us, but then tell the media they want to enrich uranium. We will find out the truth." #US#Trump#Iran#MilitaryResponse#PeaceTalks#Ammunition#Warships#NuclearWeapons#Uncertainty#Diplomacy#Pakistan#AirForceTwo

Crypto M - Crypto News

@CryptoM · Post #64734 · 09.04.2026 г., 16:31

🚀 Uncertainty Surrounds Trump's Attendance at Mar-a-Lago Gala Terms for the April 25 official gala at Mar-a-Lago indicate that U.S. President Donald Trump may not be able to attend, and organizers reserve the right to reschedule or cancel the event. According to NS3.AI, a spokesperson from Get Trump Memes stated that Trump is still anticipated to attend both the Florida luncheon and the White House Correspondents' Dinner in Washington that evening. #Trump#MarALago#gala#uncertainty#attendance#reschedule#cancel#floridaluncheon#whitehousecorrespondentsdinner#NS3AI#GetTrumpMemes