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

Пребарај: #july2024

当前筛选 #july2024清除筛选
The Open Platform

@topco · Post #88 · 04.07.2024 г., 13:03

Boring A.P.E. (Attention Points Economy): Observations on a New Trend In the digital age, attention has become a valuable commodity, and the "Attention Points Economy" seeks to capture this value by turning simple interactions into measurable points. This concept is gaining traction, particularly in Telegram Mini apps like Notcoin and Hamster Kombat, which engage millions of users through gamified interactions. The economic value created by points rewards every beneficiary within the ecosystem. This creates micro-markets within apps and opens new opportunities for developers and users alike, potentially leading to a decentralized ecosystem where digital engagement and identity merge. Our new post explores the rapid adoption of this trend and its broader significance. #July2024#GameFi#TelegramMiniApps#Telegram#Notcoin

The Open Platform

@topco · Post #89 · 12.07.2024 г., 12:55

Native USDt on TON: Adoption and Market Dynamics Q2 2024 On April 19th, Pavel Durov, CEO & Founder of Telegram, Paolo Ardoino, CEO of Tether, and Andrew Rogozov, CEO of TOP & Wallet, announced the launch of native USDt on TON at TOKEN2049. It was designed to revolutionize peer-to-peer payments, allowing Telegram users to make USDt transfers instantly by simply sending a direct message to their contacts. With a total circulation of $580 million in just 3 months since its launch, USDt is already deeply integrated with most of TON's major protocols and dApps. This post will explore the emerging trends surrounding USDt within TON's ecosystem and its role as a Digital Dollar. Learn more about: — The premise for introducing native USDt to TON and its significance in the long-term strategy of TON and Telegram — Gasless USDt payments on TON — The context for USDt-TON’s adoption figures compared to similar metrics on other blockchains — The adoption markers of USDt-TON within the TON ecosystem — The current and future impact of USDt-TON on TON. You may be interested in: Stablecoins: Collateralized vs Algorithmic #TON#stablecoins#DeFi#July2024#USDT