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

Пребарај: #globaluncertainty

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

@CryptoM · Post #64527 · 09.04.2026 г., 06:14

🚀 Japan Considers Additional Oil Reserve Release Amid Strait of Hormuz Uncertainty Japan is contemplating the release of an additional 20 days' worth of oil reserves as early as May. According to NS3.AI, this decision comes amid ongoing uncertainties surrounding the reopening of the Strait of Hormuz. Japan's heavy reliance on the Middle East for approximately 95% of its oil supply underscores the significance of this move. Since March 16, Japan has already released around 50 days of reserves and still maintains a reserve sufficient for 230 days. #Japan#oilreserves#StraitofHormuz#oilsupply#MiddleEast#energymarket#globaluncertainty

Crypto M - Crypto News

@CryptoM · Post #64775 · 09.04.2026 г., 22:03

🚀 PRECIOUS METALS | Spot Gold and Silver Open Slightly Higher, WTI Crude Oil Rises Spot gold and silver prices opened slightly higher on Friday, alongside an increase in WTI crude oil prices. According to Jin10, the futures for the three major U.S. stock indices showed a slight decline. This movement in the commodities market comes amid ongoing global economic uncertainties, influencing investor sentiment and market dynamics. The fluctuations in precious metals and crude oil prices are closely watched by traders and analysts, as they reflect broader trends in the financial markets. #preciousmetals#gold#silver#WTI#crudeoil#economy#commodities#globaluncertainty#financialmarkets#trading#investors

Crypto M - Crypto News

@CryptoM · Post #65042 · 10.04.2026 г., 15:27

🚀 Hermès Expands Leather-Goods Production Amid Global Uncertainty Hermès has inaugurated its 25th leather-goods manufacturing facility in France, continuing its strategy to boost production despite a slowdown in luxury demand. Bloomberg posted on X, highlighting the company's commitment to growth even as geopolitical tensions, such as the Iran conflict, introduce new uncertainties to the market. Hermès remains focused on expanding its operations, aiming to meet long-term goals despite current challenges in the luxury sector. #Hermès#LeatherGoods#Luxury#Manufacturing#France#Expansion#GlobalUncertainty#LuxuryMarket#BusinessGrowth#Geopolitics

Crypto M - Crypto News

@CryptoM · Post #64541 · 09.04.2026 г., 07:05

🚀 U.S. Dollar Index Remains Stable Amid Middle East Tensions The U.S. Dollar Index (DXY) maintained stability on April 9, despite ongoing uncertainties surrounding the conflict in Iran. According to BlockBeats, the situation remains tense following a two-week ceasefire agreement between the United States and Iran. Iran continues to launch missiles and drones towards Arab nations in the Persian Gulf, while Israel has targeted Hezbollah militants in Lebanon. Iran has also informed mediators of its intention to limit the number of ships passing through the Strait of Hormuz and impose transit fees. Analysts from Commerzbank have expressed concerns, suggesting that the ceasefire may be a fragile pause in the conflict, as it inherently implies further negotiations. #USDollarIndex#MiddleEastTensions#IranConflict#DXY#Ceasefire#StraitOfHormuz#PersianGulf#Israel#Hezbollah#Commerzbank#TransitFees#GlobalUncertainty