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

Резултати

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

Пребарај: #comingsoon

当前筛选 #comingsoon清除筛选
HDB

@SingaporeHDB · Post #982 · 21.10.2021 г., 01:35

#ComingSoon: An integrated development at Yew Tee which will house 2-room Flexi flats for seniors, a community club, a polyclinic, retail shops, and Choa Chu Kang’s first hawker centre all under one roof! P.S. The 2-room Flexi flats will be launched in the upcoming November sales exercise, along with over 4,000 flats in Hougang, Jurong West, Kallang/Whampoa and Tengah 😊 (Photo credit: MKPL Architects)

Hashtags

SingSing Announcement

@singsingchannel · Post #852 · 28.09.2024 г., 05:57

🚨The SingSing Tycoon NFT Marketplace is on its way🚨 💥 Trade exclusive NFTs for profits. 💎 Flex your collection. 🎮 Unlock game-changing assets. Get ready to take your SingSing Tycoon experience to the next level! 🚀 🔜 Your favorite NFTs, all in one place—stay tuned for more details 👀 #NFT#SingSingMarketplace#ComingSoon 🎤Announcement | Chat | X (Twitter) | Website | Game

SingSing Announcement

@singsingchannel · Post #972 · 08.11.2024 г., 11:21

🚀 Big News Alert 🚀 $SING is gearing up for an exciting CEX listing next week! 📈 But we’re keeping the exchange a secret…for now! 🤫 Guess the CEX & get ready for the reveal! 🔥 #SingSing#CEXListing#ComingSoon 🎤Announcement | Chat | X (Twitter) | Website | Game

MXPlayer Official

@mxofficialchannel · Post #1267 · 27.03.2026 г., 09:36

Kaptaan | Official Teaser | Amazon MX Player Language: Hindi Genre: Drama, Crime, Thriller jahan insaaf ki zarurat ho, wahan Kaptaan ki entry pakki hai ⚖️🔥 Kaptaan, coming soon, only on Amazon MX Player for FREE! watch now🔗- https://youtu.be/X4Kb6K7B61o #Kaptaan#AmazonMXPlayer#ComingSoon

MXPlayer Official

@mxofficialchannel · Post #1263 · 25.03.2026 г., 08:34

Famously Fit with Sophie | Official Trailer | Amazon MX Player Language: Hindi Genre : Fitness based Chat Show Bollywood fitness secrets, finally out 👀 Famously Fit with Sophie, coming soon only on Amazon MX Player for FREE! watch now - https://youtu.be/Cs6lCuRgBC8 #AmazonMXPlayer#ComingSoon#FamouslyFitwithSophie

Quasark.io - Announcement

@quasark_channel · Post #7 · 04.07.2023 г., 07:49

📢CLOSED BETA WHITELIST CLOSED Attention, QuasarK Community: the application period for our closed beta is now officially closed. We want to express our heartfelt thanks ❤️ to everyone who applied and showed their interest in being a part of this exclusive testing phase. Your support and enthusiasm mean the world to us! 👏 🚀 But hold on tight, because the journey is just getting started! In a matter of days we’ll be reaching out to our whitelisted beta testers🏆. If you made it to the whitelist, keep an eye on your notifications and direct messages 📩 as we will be sharing important updates and instructions with you. BEWARE OF SCAM! Stay tuned for more updates and announcements 👀 as we continue to make progress towards the launch of QuasarK. We appreciate your ongoing support and look forward to embarking on this exciting journey together! #QuasarK#ClosedBeta#BetaTesters#ComingSoon

ПретходнаСтраница 1 од 4Следна