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

Пребарај: #ageofmars

当前筛选 #ageofmars清除筛选

💵 How to make money in the P2E game Age of Mars? 💵 AGE OF MARS is a 3D game in which you conquer Mars. You will need to produce water, oxygen, and rocket fuel to trade these resources for real money How it works 👇 1️⃣ Buy Aqua NFT and (or) Planta NFT of any rarity - from common to legendary. The higher the rarity of an NFT, the greater its profitability. 2️⃣ Place your NFTs on the playing field. They will become in-game assets and will generate daily resources that can be exchanged for MRT tokens. This token is traded on the Pancake Swap exchange as MRT/USDT pair, which means you can instantly top-up your USDT wallet. 3️⃣ Increase your income - upgrade your NFTs to level 10. Yield at Level 10 can be 101% higher than at Level 1. 4️⃣ Try minting - create a new NFT from two existing ones. Minting is available for Level 10 tokens. You can play together with your team members and earn passive income - up to 15% from NFT sales and up to 80% from all resources generated in your team. 💰How to start earning 💰 ➡️Register using the link ➡️ Top up your balance ➡️ Buy NFTs on the marketplace ➡️ Place them on the in-game map ➡️ Collect resources and exchange them for USDT REGISTRATION | TELEGRAM CHANNEL #P2E#Play2Earn#AgeOfMars

​​🎙TOP TIER PROJECT ANNOUNCEMENT 🔥🔥🔥 👉Age of Mars - a P2E game. Make money on the colonization of Mars 💵👽💵 📌A whole new generation of P2E games is coming: they offer a free 2 play model, high-quality graphics, addictive gameplay, and a sustainable economic model. It is a fully-fledged 3D game in which you are required to turn Mars into a habitable planet. 📌The spaceship will take you to Mars, where your mission will be to create a habitable planet. You will get to develop your base and extract liquid resources that can be instantly converted into MRT utility tokens (MRT 👉 USDT). 👩‍🚀 Level up your NFTs and earn more. Depending on the rarity of the NFT, the yield on level 10 can be 101% higher than on level 1. In addition, level 10 unlocks Minting, the process of creating a new NFT at the expense of two NFTs you already own. 🧨 Age of Mars has a dedicated game mode for teams. You can earn up to 15% from NFT sales and up to 80% of the resources generated in your team. These are the best rewards across all blockchain games! 🤌 👉You can join the conquest of Mars by following the link.🔥🔥🔥 REGISTRATION| Telegram #P2E#Play2Earn#AgeOfMars