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

Пребарај: #ufc305

当前筛选 #ufc305清除筛选
bjjfanaticsinstructionals

@bjjfanaticsinstructionals · Post #1790 · 31.03.2025 г., 16:17

😁Unpredictable Stand-Up Attacks: High-Level Setups & Execution For Devastating Punches, Kicks By Georges St. Pierre😁 ➡️Unlock the secrets to devastating stand-up striking with Georges St. Pierre, one of the greatest mixed martial artists of all time, in his groundbreaking instructional series, Unpredictable Stand-Up Attacks: High-Level Setups &Execution for Devastating Punches, Kicks. ➡️In this expertly crafted program, GSP—known for his mastery of strategy, timing, and versatility—breaks down the art of unpredictable striking and its application in both striking and MMA. ➡️Whether you’re a beginner looking to build a solid foundation or an advanced fighter aiming to sharpen your skills, GSP’s proven techniques will elevate your striking game to new heights $197😍$19.99😍 ❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️ 📱Payment: 📱📱📱 💰Submeta FOR FREE 🌈UFC Picks 👑MasterClass ✈️@bjjfanaticsinstructionals #GSP#UFC#Striking#UFC305 💁‍♀️Buy 💁‍♀️

bjjfanaticsinstructionals

@bjjfanaticsinstructionals · Post #1792 · 31.03.2025 г., 16:43

😁Mastering Takedowns: All Tricks & Techniques For Unstoppable Takedowns By Georges St. Pierre😁 ➡️Unlock the secrets to dominating takedowns with Mastering Takedowns: All Tricks &Techniques for Unstoppable Takedowns by Georges St-Pierre, one of the greatest martial artists of all time. ➡️Whether you’re a beginner looking to build a strong foundation or an advanced athlete refining your techniques, this instructional provides actionable strategies, drills, and tactics used by the best in the business ➡️Georges St-Pierre’s unique approach blends traditional grappling knowledge with modern MMA strategy, giving you the tools to control the fight from the moment the first punch is thrown. $197😍$19.99😍 ❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️ 📱Payment: 📱📱📱 💰Submeta FOR FREE 🌈UFC Picks 👑MasterClass ✈️@bjjfanaticsinstructionals #GSP#UFC#Takedowns#MMA#UFC305 💁‍♀️Buy 💁‍♀️