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

Пребарај: #ngc6946

当前筛选 #ngc6946清除筛选
Universe Mysteries 🪐

@cosmomyst · Post #40 · 30.07.2025 г., 08:51

🪐 The faint spiral galaxy NGC 6946, also called the "Fireworks Galaxy," has hosted ten recorded supernovae in the past century—more than any other galaxy of its size. Its dazzling history of stellar explosions illuminates clouds of gas and dust, revealing fresh bursts of star formation and the ongoing cycle of cosmic destruction and rebirth. ✨ #supernovae⚡#galaxies⚡#NGC6946 👉subscribe Universe Mysteries

Universe Mysteries 🪐

@cosmomyst · Post #147 · 17.08.2025 г., 16:11

🪐 In the galaxy NGC 6946, astronomers have identified a pair of medium-sized black holes locked in a close orbit, slowly spiraling toward each other. As they draw closer together, they send out ripples in space called gravitational waves—faint yet powerful signals that help scientists trace the invisible dance of these hidden giants across millions of light-years. ✨ #blackholes⚡#NGC6946⚡#gravitationalwaves⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries

Universe Mysteries 🪐

@cosmomyst · Post #426 · 15.10.2025 г., 12:21

🪐 In the galaxy NGC 6946, astronomers captured the supernova SN 2017eaw, a brilliant explosion marking the death of a red supergiant star about 22 million light-years away. This supernova was so bright that for a while, it outshone all the other stars in its galaxy combined, scattering newly forged elements like oxygen and silicon into space to seed future generations of stars and planets. ✨ #supernovae⚡#NGC6946⚡#cosmicexplosions⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space 👉subscribe Universe Mysteries 👉more Channels ​