#ПростоеВебПриложение
Код из видео:
Файл 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>
Код из видео:
Файл 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 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')
Код из видео:
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)
Код из видео:
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()
Код из видео:
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 вашего чата)
Код из видео:
Уведомления.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 вашего чата)
#БазаДанныхВPython
Код из видео:
import sqlite3
conn = sqlite3.connect('example.db')
cur = conn.cursor()
cur.execute('''CREATE TABLE IF NOT EXISTS товары (дата text, товар text, количество real, цена real)''')
cur.execute("INSERT INTO товары VALUES ('2021-11-12', 'Журнал', 100, 200)")
products = [('2021-11-13', 'Ручка', 100, 30),
('2021-11-14', 'Тетрадь', 100, 50),
('2021-11-15', 'Мел', 100, 15),
]
cur.executemany("INSERT INTO товары VALUES (?, ?, ?, ?)", products)
cur.execute("SELECT * FROM товары")
for i in cur.fetchall():
print(i)
conn.commit()
conn.close()
Код из видео:
import sqlite3
conn = sqlite3.connect('example.db')
cur = conn.cursor()
cur.execute('''CREATE TABLE IF NOT EXISTS товары (дата text, товар text, количество real, цена real)''')
cur.execute("INSERT INTO товары VALUES ('2021-11-12', 'Журнал', 100, 200)")
products = [('2021-11-13', 'Ручка', 100, 30),
('2021-11-14', 'Тетрадь', 100, 50),
('2021-11-15', 'Мел', 100, 15),
]
cur.executemany("INSERT INTO товары VALUES (?, ?, ?, ?)", products)
cur.execute("SELECT * FROM товары")
for i in cur.fetchall():
print(i)
conn.commit()
conn.close()