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

Пребарај: #nexuswallet

当前筛选 #nexuswallet清除筛选

$DROP token review, Nexus Wallet news and a small bonuseaster egg The coin from the DropHunter project will work on the #TON network. Here is its application: 🟨 In-game currency – purchase of artifacts, skins, participation in tournaments and sweepstakes. 🟨 Staking – the longer you hold coins, the greater the rewards, exclusive artifacts and tickets to special events. 🟨 Impact on game development (DAO) — voting for updates and new features, the strength of your vote will depend on the number of #DROP tokens. 🟨 Discounts on in-game purchases and payment for services in the #DropHunter ecosystem. 🫥 In one of the next updates, the autofarm function will appear (look at screenshot above), there will be less routine and we will be able to farm coins much easier. Nexus Wallet News 👛 The team has a main product — Nexus Wallet, which we have already announced. The #NFT module will be launched soon and the first collection to be launched will be TON HERO: 🟩 Uniqueness – each NFT in the collection has its own style and image. 🟩 Utilities — You gain access to exclusive features and privileges in the #NexusWallet ecosystem. 🟩 Profit – NFT holders will receive daily payouts of 0.02 to 1 $TON per Nexus Wallet. 🚀 Game | Channel | Nexus

💰Drop Hunter launched the first airdrop in $DROP token! 🎟 In #airdrops tab, it is now possible to exchange farmed coins for tickets, which increase the chances of receiving their $DROP token. The conditions are as usual simple: 🟨Log into the bot and go to the "airdrops" tab 🟨 Invite 3 friends and subscribe to the desired channels 🟨 Exchange collected coins for tickets 🟨 Wait for the end and check the internal wallet 🚀 Let us remind you that, according to the team, $DROP is a utility token of the ecosystem, which includes the projects: #Amabit, #DropHunter and #NexusWallet. It will be used to pay for internal services. 💎Rewards: 500K out of 8M total supply. 🟡 Drop type – raffle 🟡 Total winners – 3300 people 🟡 $DROP for each winner 🔥 Closer to autumn, the team is planning to list the #DROP token on a major exchange, so let's continue to farm and participate in all their airdrops. Game | Chat | Channel | YouTube | Nexus