Справочник Программиста
6.28K subscribers
1.36K photos
387 videos
64 files
1.71K links
По рекламе - @it_start_programmer
Мои курсы - @courses_from_it_start_bot
Сайт - https://it-start.online/
YouTube - https://www.youtube.com/@it_start
Реклама на бирже - https://telega.in/c/programmersGuide_1

Предложить идею: @it_start_suggestion_bot
Download Telegram
#ДиктофонНаPython
Код из видео:

import sounddevice
from scipy.io.wavfile import write


def voice_recorder(seconds, file):
print('Запись началась')
recording = sounddevice.rec((seconds * 44100), samplerate=44100, channels=2)
sounddevice.wait()
write(file, 44100, recording)
print('Запись завершена')


voice_recorder(10, 'Запись.wav')
#КонвертацияДанныхИФайловВPDF
Код из видео:

from fpdf import FPDF

pdf = FPDF()

pdf.add_page()
pdf.set_font('Arial', size=25)

with open('Test.txt', 'r') as f:
for i in f:
pdf.cell(200, 10, txt=i, ln=1, align='C')

pdf.output('pdfTest.pdf')
#ПростоеВебПриложение
Код из видео:

Файл main.py:

import eel

eel.init('web')
eel.start('index.html', size=(700, 700))

Файл index.html:

<html>
<head>
<title>Журнал</title>
<meta charset="UTF-8">
<style type="text/css">
body{
background: #FFDEAD;
}
table{
table-layout: fixed;
width: 100%;
border-collapse: collapse;
}
td, th{
border: 2px solid black;
}
</style>
</head>
<body>
<h1 align="center">Журнал</h1>
<table id="journal">
<tr>
<th>Абрамович</th>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<th>Гордон</th>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<th>Карен</th>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<th>Юрий</th>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<tr>
<th>Юлий</th>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
</table>
<script>
let cells = document.querySelectorAll("#journal td");

for (let cell of cells) {
let mark = Math.floor(Math.random() * 4) + 2;
let colors = {
2: "red",
3: "yellow",
4: "green",
5: "lime",
};
cell.innerText = String(mark);
cell.style.backgroundColor = colors[mark];
}
</script>
</body>
</html>
👍1
#ПроверкаНаОпечатки
Код из видео:

from spellchecker import SpellChecker

spell = SpellChecker(language='ru')

with open('text.txt', 'r', encoding='utf-8') as f:
misspelled = f.read()
misspelled = misspelled.split(' ')
print(misspelled)

misspelled = spell.unknown(misspelled)
print(misspelled)

for word in misspelled:
print(spell.correction(word))
#СозданиеГифки
Код из видео:

from moviepy.editor import *

clip = (VideoFileClip('video.mp4').subclip(3, 7).resize(0.5))

clip.write_gif('gifka.gif')
#МатрицаНаPython
Код из видео:

from tkinter import *
import random
import time

root = Tk()
root.title('Матрица')
root.geometry('700x700+300+300')
root.resizable(width=False, height=False)

c = Canvas(root, width=700, height=700, bg='black')
c.pack()

alphabet = 'qwertyuiop[]{}asdfghjkl;zxcvbnm<>?/|'
alphabet.split()
print(alphabet)
print(len(alphabet))
h = 0

while True:
c.delete('t' + str(h))
for i in range(1, 35):
r = random.randint(0, 35)
ct = c.create_text(20 * i, h, text=str(alphabet[r]), fill='lime', font=('Comic Sans MS', 11), tag='t' + str(h))
rdm = random.randint(1, 10)
for j in range(10):
c.move(ct, 0, rdm)
c.update()
h += 20
if h >= 650:
h = 0

time.sleep(0.1)
👍1
#КонвертацияPDFвTXT
Код из видео:

import pdfminer.high_level

with open('pdfTest.pdf', 'rb') as file:
file1 = open(r"pdfTest.txt", "a+")
pdfminer.high_level.extract_text_to_fp(file, file1)
file1.close()
#СозданиеУведомленийЧерезТелеграмБота
Код из видео:

Уведомления.py
from notifiers import get_notifier
import time
from TOKEN import token, chatId

while True:
what = input('О чём напомнить?\nДля выхода отправьте \'exit\'\n')
if what == 'exit':
break
else:
t = input('Через сколько минут напомнить?\n')
t = int(t) * 60
time.sleep(t)
telegram = get_notifier('telegram')
telegram.notify(token=token, chat_id=chatId, message=what)

TOKEN.py
token = 'Токен вашего бота'
chatId = (Id вашего чата)
Уже 20 минут длится обработка видео.