@wukongcm · Post #46 · 19.11.2024 г., 03:27
Hey WUKERS, 🔥 This Game Is Yours, We Need You! 👉 Show yourself: https://t.me/bmwukongbot/join?startapp=L29WAAMR #Wukong
Hashtags
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
Пребарај: #wukong
@wukongcm · Post #46 · 19.11.2024 г., 03:27
Hey WUKERS, 🔥 This Game Is Yours, We Need You! 👉 Show yourself: https://t.me/bmwukongbot/join?startapp=L29WAAMR #Wukong
Hashtags
@wukongcm · Post #44 · 14.11.2024 г., 05:16
🔥Welcome to Wukong – where every step is a challenge. Here, you don’t just earn Wk; you face fierce trials to move closer to the true treasure – the boundless power of the sacred scrolls. Let's join Wukong to conquer the missions and discover the secret rewards that await you. ➡️ Are you ready to step into legend? https://t.me/bmwukongbot/join?startapp=L29WAAMR #Wukong
Hashtags
@wukongcm · Post #42 · 25.10.2024 г., 07:39
⚡️ Transform your crypto experience with CoinEx, just like Wukong's 72 transformations. Get started today! ➡️ Register CoinEx: https://www.coinex.com/register?refer_code=webgh #Wukong#CoinEx
@wukongcm · Post #39 · 21.10.2024 г., 07:47
⚡️ Defy the odds like Wukong in battle. On CoinEx, every trade is a step toward your next big victory! ➡️ Register CoinEx: https://www.coinex.com/register?refer_code=webgh #Wukong#CoinEx
@wukongcm · Post #36 · 17.10.2024 г., 07:51
✔️ Master the art of trading, just like Wukong mastered his powers. Start with CoinEx today and become a crypto legend ➡️ Register CoinEx: https://www.coinex.com/register?refer_code=webgh #Wukong#CoinEx
@wukongcm · Post #34 · 12.10.2024 г., 07:55
✔️ Forge your own crypto legend with CoinEx, just like Wukong in his journey. Start trading today! ➡️ Register CoinEx: https://www.coinex.com/register?refer_code=webgh #Wukong#CoinEx
@wukongcm · Post #33 · 11.10.2024 г., 07:53
💥 Every trade is a step closer to victory! CoinEx is your battlefield—are you ready to conquer? ➡️ Register CoinEx: https://www.coinex.com/register?refer_code=webgh #Wukong#CoinEx
@wukongcm · Post #31 · 09.10.2024 г., 08:26
👍Like Wukong battling epic bosses, conquer your crypto journey with CoinEx. Sign up now and get ready to take on the world of digital assets! ➡️ Register CoinEx: https://www.coinex.com/register?refer_code=webgh #Wukong#CoinEx
@wukongcm · Post #43 · 26.10.2024 г., 07:42
💥 Take on the crypto world like a true warrior with OKX. Your journey starts now! ➡️ Get reward on OKX: https://www.okx.com/join/84940417 #Wukong#OKX
@wukongcm · Post #40 · 22.10.2024 г., 07:58
✔️ Strike fast and win big, just like Wukong! Join OKX and experience lightning-fast trades! ➡️ Get reward on OKX: https://www.okx.com/join/84940417 #Wukong#OKX
@wukongcm · Post #37 · 18.10.2024 г., 07:53
✨ Journey through the crypto universe with OKX. Your path to victory is clear—start trading now! ➡️ Get reward on OKX: https://www.okx.com/join/84940417 #Wukong#OKX
@wukongcm · Post #35 · 16.10.2024 г., 07:48
🎁 No need for 72 transformations—on OKX, all you need is one account to start trading! ➡️ Get reward on OKX: https://www.okx.com/join/84940417 #Wukong#OKX