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

Резултати

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

Пребарај: #algae

当前筛选 #algae清除筛选
Interesting Planet 🌍

@interesting_planet_facts · Post #960 · 24.10.2025 г., 18:11

🌎 Off the coast of Australia, the mysterious "pink lakes" like Lake Hillier owe their color to the algae Dunaliella salina, which produce red pigments in salty environments. Lake Hillier’s pink hue remains stable even when bottled, due to the unique chemistry of its saline water. ✨ #ocean⚡#mystery⚡#algae 👉subscribe Interesting Planet 👉more Channels ​

Interesting Planet 🌍

@interesting_planet_facts · Post #588 · 19.08.2025 г., 13:22

🌎 Red tides sometimes turn the ocean a rusty red or brown—caused by massive blooms of algae packed with pigments. These blooms can release toxins that harm fish and even impact local air quality, making ocean color changes a sign of dramatic ecological shifts. ✨ #ocean⚡#algae⚡#pigments 👉subscribe Interesting Planet

Interesting Planet 🌍

@interesting_planet_facts · Post #1305 · 20.02.2026 г., 12:11

🌎 Red rain fell in the Indian state of Kerala in 2001, coloring streets and clothing. Scientists found the cause was airborne spores from local algae cells. Some showers were bright red for up to two months. ✨ #phenomena⚡#weather⚡#algae 👉subscribe Interesting Planet 👉more Channels ​