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

Пребарај: #fruitcircusparty

当前筛选 #fruitcircusparty清除筛选
TRUE LABS

@truegames · Post #18 · 24.06.2024 г., 16:56

Only 3 Days Until FRUIT CIRCUS PARTY! 🍉🎪 Why wait for the fun? The Buy Bonus feature lets you jump straight into the bonus round, where multiplicative multipliers never reset between spins. More spins, more multipliers, more mayhem! 🎢 Tick-tock, the madness begins in just 3 days. June 27th – mark the date! ➡️DEMO: https://bit.ly/demo-fcp #FruitCircusParty#MultiplicativeMultipliers#BuyBonus#TrueLab#TrueGames#TrueSlots

TRUE LABS

@truegames · Post #15 · 11.06.2024 г., 20:00

FRUIT CIRCUS PARTY brings fruit carnage to a whole new level! Step right up, there's a new circus in town! 🎪 Cascading wins unlock fresh combos & crank up the multipliers. Madness begins June 27th! 🗓️ ➡️ DEMO: https://truelab.games/games/fruit-circus-party #FruitCircusParty#CascadingWins#MultiplierChaos#TrueLab#TrueGames#TrueSlots

TRUE LABS

@truegames · Post #19 · 27.06.2024 г., 19:26

BOOM! The Fruit Circus Party is in town tonight! 💥 The wait is over, so It's finally time to unleash those unlimited multiplicative multipliers and kick off the mayhem! Use the Buy Bonus to plunge straight into the bonus round, where multipliers only head in one direction - UPWARDS. Because who needs limits, right? Fruit Circus Party is OUT NOW! 🚀 ➡️ SPIN IT: https://bit.ly/demo-fcp #FruitCircusParty#OUTNOW#MultiplicativeMultipliers#BuyBonus#TrueLab#TrueGames#TrueSlots

TRUE LABS

@truegames · Post #17 · 18.06.2024 г., 10:01

Tired of boring fruit games? We’ve got you covered. Our latest game, FRUIT CIRCUS PARTY, features multiplicative multipliers with no limits! That’s right, endless chaos and infinite potential! 🎢 Charge the multipliers by landing wins and triggering cascades. The more you win, the crazier it gets, and we mean CRAZIER! You can even use the Buy Bonus to head straight into the bonus round, where multipliers don't reset and only head upwards. Because who needs stability, right? 🎪💥 We’re just 10 days away from launching this fruity frenzy. Mark your calendars for June 27th! Can't wait? Hit up the demo right here! ➡️https://bit.ly/demo-fcp #FruitCircusParty#MultiplicativeMultipliers#CascadingWins#BuyBonus#TrueLab#TrueGames#TrueSlots