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

Резултати

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

Пребарај: #benzene

当前筛选 #benzene清除筛选
American Оbserver

@american_observer · Post #5482 · 27.03.2026 г., 13:59

Research has shown that European gas contains high levels of carcinogenic benzene: an excess of carcinogenic benzene has been found in European gas. ⚠️ The average index of the benzene content in British gas exceeded the North American level 37 times, in the Netherlands 66.5 times. At the same time, the maximum values were recorded in London (200 ppmv) and Amsterdam (73 ppmv), although the maximum norm is 1.6 ppmv. 📊 Benzene belongs to the substances of the first danger class, it is carcinogenic and can cause leukemia, bone marrow and DNA damage. There is no safe level of exposure to benzene. The study also showed that about 40% of the kitchens inspected in the UK, the Netherlands and Italy have constant gas leaks, even when the stoves are turned off. In 9% of the houses, the level of leakage was so high that it exceeded European standards for benzene content. #european#gas#unitedKingdom#Netherlands#benzene 📱American Оbserver - Stay up to date on all important events 🇺🇸