import pywinauto
import time
f = open("test.txt",'r',encoding = 'utf-8')
catalog = f.read().splitlines()
while True:
for f in catalog:
try:
app=pywinauto.Application().connect(path=f)
except pywinauto.application.ProcessNotFoundError:
print(f, 'not found')
else:
print(f)
time.sleep(1)
import psutil
import time
f = open("test.txt",'r',encoding = 'utf-8')
catalog = f.read().splitlines()
def check_process(process_exe):
for proc in psutil.process_iter():
try:
if process_exe.lower() in proc.exe().lower():
return True
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
pass
return False
while True:
for f in catalog:
if check_process(f):
print(f)
else:
print('...')
time.sleep(1)
#загружаем json из файла
with open("D:\\myfile.json","r",encoding="utf-8") as fp:
data=json.load(fp)
# добавляем/удаляем из data
...
# сохраняем результат в файл
with open("D:\\myfile.json","w",encoding="utf-8") as fp:
json.dump(data,fp,ensure_ascii=False,indent=4)
Как сделать так чтобы бот показал в ответном сообщении, какое число назвал пользователь:) самому пользователю?
@bot.message_handler(content_types=['text'])
def start_text(message):
if message.text.isdigit():
bot.send_message(message.chat.id, 'Ага, цифра!')
user_num = int(message.text)
if user_num in range(1,100):
bot.send_message(message.chat.id, 'Отлично, цифра в диапазоне 1..99')
else:
bot.send_message(message.chat.id, 'К сожалению, цифра выходит за диапазон 1..99')