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

Резултати

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

Пребарај: #pininfarina

当前筛选 #pininfarina清除筛选
Auto Life

@revheadcrypto · Post #286 · 09.08.2024 г., 20:09

🌟🚗Introducing the Pininfarina B95 Gotham!🦇✨ Inspired by the legendary hero Bruce Wayne, this hypercar is designed for those who dare to push the limits! 💪🔥 Featuring the iconic Wayne Enterprises logos, the B95 Gotham showcases a stunning design that embodies the spirit of Gotham City. 🏙️🖤 On the driver's door, you’ll find the powerful quote: "All men have limits... I ignore mine." — a true testament to the Dark Knight’s relentless pursuit of excellence. 🗣️💬 The car's displays come alive with custom graphics, and even the virtual assistant speaks in the voice of Alfred Pennyworth, bringing a touch of elegance and sophistication to your driving experience. 🎩🤖 And this isn’t just a show car! A limited number of these masterpieces will be produced by order. Don’t miss your chance to own a piece of superhero history! 🌌🚀 #Pininfarina#B95Gotham#BruceWayne#Hypercar#Auto🖤🔧

Auto Life

@revheadcrypto · Post #332 · 18.08.2024 г., 12:05

🚗✨ Introducing the Unique Pininfarina Battista Targamerica! 🌟 Pininfarina has unveiled a stunning roadster, the Battista Targamerica, crafted for a special client who already owns the Battista coupe. This exclusive model features a sleek convertible design with a refined rear end. 🌈🛠️ One of the standout elements of the interior is a bespoke cigar holder and humidor, specially made for this one-of-a-kind vehicle. The custom aluminum and glass case can hold up to three cigars, adding a touch of luxury to every drive. 💨💼💨 Under the hood, the Battista Targamerica boasts the same incredible four-motor powertrain as the Rimac Nevera, delivering a jaw-dropping 1900 horsepower!⚡️💥 It accelerates from 0 to 60 mph in under 2 seconds!🚀🔥 This masterpiece is not just a car; it's an experience! #Pininfarina#BattistaTargamerica#LuxuryCars#Roadster#CustomDesign#CigarLovers#ElectricSupercar#Performance#Auto🚗💖