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

Резултати

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

Пребарај: #hurso

当前筛选 #hurso清除筛选
Addis Standard

@addisstandardeng · Post #21275 · 02.02.2026 г., 08:49

News: #UK Foreign Secretary visits Addis Abeba, signs energy and investment cooperation deals after talks with #PM_Abiy, #FM_Gedion #British Foreign Secretary Yvette Cooper paid an official visit to #Addis_Abeba, where she held talks with Prime Minister Abiy Ahmed and Foreign Minister Gedion Timothewos, culminating in the signing of energy and investment cooperation agreements between Ethiopia and the United Kingdom. Prime Minister Abiy said his discussions with Cooper focused on key bilateral and regional issues of mutual interest. During the visit, the two sides oversaw the signing of a Memorandum of Understanding on technical cooperation in public investment and asset management under the Ethiopia Investment Advisory Facility. They also witnessed the conclusion of a joint development agreement for two major power transmission projects: the #Hurso–#Aysha 400 kV Transmission Project and the #Degehbur–#Kebridehar 132 kV Transmission Project. The projects .... Read more: https://addisstandard.com/?p=54891