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

Резултати

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

Пребарај: #wtf

当前筛选 #wtf清除筛选

Curated Crypto | ꘜ 🤑WTF: ETH options open interest just hit a 1.5-year high! Degens are loading up on longs, while whales are stacking ETH at all-time record pace! But hedge funds are going mega short - CME ETH futures short positioning just keeps smashing new records! Green But Red in real life! #WTF

Hashtags

Viral Today

@viral_today · Post #3327 · 23.06.2025 г., 15:31

An Italian car enthusiast built the world’s narrowest fully functional car based on a Fiat Panda @Viral_Today / #wtf

Hashtags

Viral Today

@viral_today · Post #3235 · 22.11.2024 г., 13:30

When too many kids want to sled, you just connect 47 sleds to one tractor and call it a day! @Viral_Today / #wtf

Hashtags

Viral Today

@viral_today · Post #3224 · 18.11.2024 г., 15:30

The suspect attempted to escape an interrogation room by breaking through the wall while no one was watching—only to be caught shortly after. @Viral_Today / #wtf

Hashtags

Viral Today

@viral_today · Post #3216 · 16.11.2024 г., 12:30

When you drive an electric car but miss the roar of an engine, so you get creative with sound effects @Viral_Today / #wtf

Hashtags

Viral Today

@viral_today · Post #3158 · 26.10.2024 г., 17:28

Imagine a coffee table that moves around the house by itself—well, you don’t have to anymore because it’s real. It’s just as fascinating as it is creepy. @Viral_Today / #wtf

Hashtags

123•••5•••10•••15•••20•••25•••30•••35•••40•••45•••50•••5556
ПретходнаСтраница 1 од 56Следна