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

Резултати

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

Пребарај: #techart

当前筛选 #techart清除筛选
Auto Life

@revheadcrypto · Post #526 · 25.09.2024 г., 11:41

🚗✨Introducing the Techart Monochrome: A 800-HP Tribute to the Porsche 911!🎉 🔧Engine: 3.8L Turbo Flat-Six from the 911 Turbo S, tuned to an astonishing 800 HP and 950 Nm of torque! ⚡️0-100 km/h: Just 2.5 seconds! 🏁Top Speed: A thrilling 350 km/h! 🌬️ The aerodynamic kit generates 4x more downforce than the standard 911, reducing lift by 45% at 140 km/h! 🏆 Only 20 units of this exclusive coupe will be produced! #Techart#Porsche911#Monochrome#Supercar#800HP#CarEnthusiast#LimitedEdition#Auto

Auto Life

@revheadcrypto · Post #391 · 26.08.2024 г., 20:00

🚗✨ Introducing the New Techart Aero Kit I for the Updated Porsche Cayenne! ✨🚗 Get ready to elevate your ride with this stunning aerodynamic body kit that not only enhances the aggressive look of the Cayenne but also improves its aerodynamics! 💨🔥 While the price of the kit is yet to be announced, Techart is already working on even more aggressive versions to take your driving experience to the next level! 🚀💪 #Techart#PorscheCayenne#AeroKitI#CarEnthusiast#LuxuryCars#Aerodynamics#UpgradeYourRide#Auto

Themes

@ThemesM8 · Post #316 · 10.07.2024 г., 23:48

https://t.me/addtheme/CyberGlow_ThemesM8 And finally, after a long time, I made a new theme again. I put a lot of time into this one to ensure that all the colors are correct. I even adjusted the story colors, channel statistics' colors, and more. By the way, as always, it also supports Desktop. Let's begin with a good theme. Enjoy! #Android#Desktop#AndroidTheme#DesktopTheme#Dark#CyberpunkTheme#NeonTheme#TechTheme#DarkTheme#GlowingTheme#DigitalArt#CyberArt#TechArt#TelegramTheme#TelegramThemes#CustomThemes#ThemeDesign#purple#ThemeCreator#DarkMode#TechAesthetics#CyberAesthetics#HackerStyle#FuturisticStyle#NeonLights#GlowInTheDark#DigitalAesthetics#CyberFashion#TechWear#NeonWear#HoodieStyle#LEDLights#TechAccessories#ThemeSupport#DesktopThemes#MobileThemes#CyberpunkArt#NeonVibes#GlowingEyes#FuturisticFashion#CyberGirl#LEDMask#HoodieFashion#NeonPink#NeonPurple#DarkAesthetic#CyberMask#FuturisticLook#TechnoFashion#NeonGlow#GlowingMask#SciFiArt#TechnoAesthetic#CyberBeauty#NightMode#CyberMood#DigitalFashion#CyberTech#NeonAesthetic#LEDGlow#ElectricVibes#TechWearFashion#FuturisticHoodie#NeonDrip#TechBeauty#LEDStyle#DarkFashion#CyberFashionista#GlowingTech#FutureFashion#CyberVibes#NeonDreams#HackerFashion#TechnoChic#NeonLightsFashion 🩷@ThemesM8 🩷 ⭐️ BOOST ⭐️