os.system('rar a <файл.rar> <файл_который_нужно_добавить_в_архив>')
import cv2
# Включаем первую камеру
cap = cv2.VideoCapture(0)
# "Прогреваем" камеру, чтобы снимок не был тёмным
for i in range(30):
cap.read()
# Делаем снимок
ret, frame = cap.read()
# Записываем в файл
cv2.imwrite('cam.png', frame)
# Отключаем камеру
cap.release()
import speech_recognition as sr
from time import sleep
import sys
def on_listen(recognizer, audio):
# print('on_listen')
try:
text = recognizer.recognize_google(audio, language='ru-RU').lower()
except sr.UnknownValueError as e:
pass
else:
print('Вы сказали:', text)
r = sr.Recognizer()
with sr.Microphone() as source:
r.pause_threshold = 1
print('Тихо...')
r.adjust_for_ambient_noise(source, duration=1)
print('Нажмите Enter для завершения')
print('Говорите...')
r.listen_in_background(sr.Microphone(), on_listen, phrase_time_limit=5)
input()
облачные сервисы, ML, data analitics.
import pyowm
city = input("Какой город вас интересует?: ")
owm = pyowm.OWM('a99967bc9ee70d5b4bd387902982f400', language = "RU")
observation = owm.weather_at_place(city)
w = observation.get_weather()
temperature = w.get_temperature('celsius')['temp']
print("В городе " + city + " сейчас температура: " + str(temperature) + " по Цельсию.")
print('Погода в указаном городе: ' + w.get_detailed_status())
# import needed modules
import android
import time
import sys, select, os #for loop exit
#Initiate android-module
droid = android.Android()
#notify me
droid.makeToast("fetching GPS data")
print("start gps-sensor...")
droid.startLocating()
while True:
#exit loop hook
if sys.stdin in select.select([sys.stdin], [], [], 0)[0]:
line = input()
print("exit endless loop...")
break
#wait for location-event
event = droid.eventWaitFor('location',10000).result
if event['name'] == "location":
try:
#try to get gps location data
timestamp = repr(event['data']['gps']['time'])
longitude = repr(event['data']['gps']['longitude'])
latitude = repr(event['data']['gps']['latitude'])
altitude = repr(event['data']['gps']['altitude'])
speed = repr(event['data']['gps']['speed'])
accuracy = repr(event['data']['gps']['accuracy'])
loctype = "gps"
except KeyError:
#if no gps data, get the network location instead (inaccurate)
timestamp = repr(event['data']['network']['time'])
longitude = repr(event['data']['network']['longitude'])
latitude = repr(event['data']['network']['latitude'])
altitude = repr(event['data']['network']['altitude'])
speed = repr(event['data']['network']['speed'])
accuracy = repr(event['data']['network']['accuracy'])
loctype = "net"
data = loctype + ";" + timestamp + ";" + longitude + ";" + latitude + ";" + altitude + ";" + speed + ";" + accuracy
print(data) #logging
time.sleep(5) #wait for 5 seconds
print("stop gps-sensor...")
droid.stopLocating()