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

Резултати

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

Пребарај: #chessio

当前筛选 #chessio清除筛选
Chessio News EN 🇬🇧

@chessio_EN · Post #128 · 09.03.2025 г., 22:04

📢 Important Chessio Update 💔 This is probably the hardest yet message we are sharing with you, our lovely Chessio Community. Before we explain further, here’s the honest truth: All this time, we’ve been running Chessio entirely from our own pockets - covering infrastructure, prize tournaments, drops, and more. We developed and maintained the platform alongside our main jobs, often sacrificing valuable family time. After much thought, we’ve decided to pause Chessio development at the end of March 2025. Additionally, we have stopped mining because we can’t promise what we aren’t sure about. We didn't receive support from the TON Foundation, even though we were among the top 10 projects out of over 1,000 in the Summer Hackathon. For example, the marketing campaign that was part of our winning prize hasn’t been launched yet. Our final drop will have a place for top 100 players of the SION leaderboard where we share 1000 USDT proportionally between players. If you are in the top 100 list, make sure you have your wallet connected. We have always been with you, and we truly appreciate your support. We hope for your understanding during these challenging times. What’s Next? Chessio will remain online on minimal hardware so you can still play games with friends and host tournaments, though it will be running on a minimal hardware, and we may need to turn off games with bots and server analysis as it eats infrastructure resources. We will be around, but the development will be on hold. But we are not giving up. Something even more exciting is coming! So stay with us and stay subscribed!🔥 Thank you for being part of this incredible Chessio and SION journey. We look forward to meeting you on the next page 😉 ❤️🧡💚💖🤍 Your Chessio Team! #Chessio#ThankYou#SeeYouSoon