TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #183 · 23 ное.

Python + bash Если вам часто требуется запускать shell команды из Python-кода, какой способ вы используете? Самый низкоуровневый это функция os.system(), либо os.popen(). Рекомендованный способ это subprocess.call(). Но это всё еще достаточно неудобно. Советую обратить своё внимание на очень крутую библиотеку sh. Что она умеет? 🔸 удобный синтаксис вызова команд как функций # os import os os.system("tar cvf demo.tar ~/") # subprocess import subprocess subprocess.call(['tar', 'cvf', 'demo.tar', '~/']) # sh import sh sh.tar('cvf', 'demo.tar', "~/") 🔸 простое создание функции-алиаса для длинной команды fn = sh.lsof.bake('-i', '-P', '-n') output = sh.grep(fn(), 'LISTEN') в этом примере также задействован пайпинг 🔸 удобный вызов команд от sudo with sh.contrib.sudo: print(ls("/root")) Такой запрос спросит пароль. Чтобы это работало нужно соответствующим способом настроить юзера. А вот вариант с вводом пароля через код. password = "secret" sudo = sh.sudo.bake("-S", _in=password+"\n") print(sudo.ls("/root")) Это не все фишки. Больше интересных примеров смотрите в документации. Специально для Windows💀 юзеров #libs#linux

Hashtags

Резултати

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

Пребарај: #endangered

当前筛选 #endangered清除筛选
Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40041 · 08.11.2025 г., 19:01

Today we present you: The takahē (Porphyrio hochstetteri) — a flightless, endemic New Zealand bird, that was once thought extinct and famously rediscovered in 1948 — has been saved from the brink of extinction by intensive conservation: captive breeding, predator control, and protected reserves. Populations have increased but the species remains threatened and needs continued protection. Around 500 birds are now known to survive. [Learn more here] Tags: #Takahē#Conservation#NZ#Endangered#LazarusSpecies

Google Facts™ [ ️@googlefactss🌎]

@googlefactss · Post #40026 · 06.11.2025 г., 15:02

We have the honor of presenting you the Cuban solenodon (Atopogale cubana) it is a small, nocturnal mammal endemic to Cuba. Secretive and evolutionarily unique, it delivers venom through grooves in its lower incisors during a bite. Populations are fragmented and declining; the species is endangered due to habitat loss and invasive predators. Increased surveys and habitat protection are needed. [Learn more here] @googlefactss #CubanSolenodon#Endangered#Conservation#Cuba#LazarusSpecies