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

Пребарај: #iranusnegotiations

当前筛选 #iranusnegotiations清除筛选
Crypto M - Crypto News

@CryptoM · Post #65135 · 11.04.2026 г., 10:24

🚀 Iran-US Negotiations Progress Slower Than Anticipated According to NS3.AI, a Pakistani government official has indicated that the ongoing negotiations between Iran and the United States are progressing at a slower pace than initially expected. The official noted that while the U.S. side seems eager to achieve specific objectives, Iran is taking a more measured approach and is not rushing to reach a conclusion. #IranUSNegotiations#SlowerProgress#USIranTalks#Diplomacy#NegotiationChallenges#Iran#UnitedStates#PakistaniOfficial

Crypto M - Crypto News

@CryptoM · Post #64997 · 10.04.2026 г., 13:15

🚀 Polymarket Odds for Strait of Hormuz Normalization Drop The probability of the Strait of Hormuz returning to normal by May 31 has significantly decreased on Polymarket, with a 6% drop in one hour and a 12% decline over 24 hours. According to Odaily, the event contract stipulates that if the International Monetary Fund's Portwatch reports a seven-day moving average of ship arrivals at the Strait of Hormuz equal to or above 60 on any date from market creation until May 31, 2026, the market will resolve as 'yes'; otherwise, it will resolve as 'no'. The daily count includes container ships, bulk carriers, roll-on/roll-off ships, general cargo ships, and tankers, excluding those not reported by the IMF Portwatch. Pakistani media confirmed today that an Iranian delegation has arrived for negotiations, with major talks between Iran and the United States scheduled for tomorrow. The discussions in Pakistan will focus on reopening the Strait of Hormuz and extending the ceasefire. Additionally, the U.S. delegation participating in the talks has departed for Islamabad, Pakistan, with U.S. Vice President Vance already on board. Before departure, Vance expressed anticipation for the negotiations on the Iran issue, stating that U.S. President Donald Trump has provided 'quite clear guidelines' for the talks. #StraitOfHormuz#Polymarket#IranUSNegotiations#MaritimeTrade#Geopolitics#Ceasefire#ShipTraffic#IMFPortwatch#Pakistan#USPolitics

Crypto M - Crypto News

@CryptoM · Post #65330 · 12.04.2026 г., 23:28

🚀 Japanese Companies Face Challenges Amid Rising Oil Prices Japanese companies are entering the earnings season with a pessimistic outlook as crude oil prices surge following the unsuccessful U.S. peace talks with Iran. Bloomberg posted on X, highlighting the impact of geopolitical tensions on the global oil market. The failure of negotiations has led to increased uncertainty, affecting various sectors in Japan that rely heavily on energy imports. As oil prices climb, businesses are bracing for higher operational costs, which could impact their profitability in the coming months. The situation underscores the interconnectedness of global events and their influence on national economies. #JapaneseCompanies#OilPrices#GeopoliticalTensions#EnergyImports#OperationalCosts#Profitability#GlobalEconomy#EarningsSeason#Bloomberg#IranUSNegotiations