import re
import string
value = 'Hel12o 16e15ple'
for number in re.findall(r'[0-9]+', value):
value = value.replace(number, string.ascii_lowercase[int(number) - 1])
import string
from typing import List
def find_numbers(string: str) -> List[int]:
temp_string = ''
numbers = []
for char in string:
if char.isdigit():
temp_string += char
elif temp_string:
numbers.append(int(temp_string))
temp_string = ''
return numbers
value = 'Hel12o 16e15ple'
for number in find_numbers(value):
value = value.replace(str(number), string.ascii_lowercase[number - 1])
latin="abcdefghijklmnopqrstuvwxyz"
text = input("Введите строку: ")
i = 0
s = ""
while i < len(text):
a = text[i]
while "0" <= a <= "9":
s += a
i += 1
if i < len(text):
a = text[i]
else:
break
i += 1
if s != "":
#print(type(s))
text = text.replace(s,latin[int(s)-1])
if len(s) > 1:
i -= len(s) - 1
s = ""
latin = "abcdefghijklmnopqrstuvwxyz"
text = input("Введите строку: ")
i = 0
s = ""
for a in text:
if "0" <= a <= "9":
s += a
continue
elif s != "":
text = text.replace(s, latin[int(s)-1])
s = ""
#Создай отдельный файл с классом типа этого
# импортируй from my_baza_class import base as b
#В своём коде вставляй где хочешь
#Пример внизу
#
import sqlite3
class base:
def __init__(self,table):
self.table = table
self.conn = sqlite3.connect("mydatabase.db")
self.cursor = self.conn.cursor()
print("Open DB")
def __del__(self):
print("CloseDB")
def insert(self, full_name,last_name):
sql = f"INSERT INTO {self.table} VALUES (null,'{full_name}', '{last_name}') "
self.cursor.execute(sql)
self.conn.commit()
print('INSERT DONE')
def select(self):
res=[]
sql = f"SELECT * FROM {self.table}"
for _ in self.cursor.execute(sql):
res.append(str(_[0]) +' '+ str(_[1])+' '+str(_[2]))
print('SELECT DONE')
return res
def create_table(self):
try:
self.cursor.execute(f"""CREATE TABLE IF NOT EXISTS {self.table}
(id integer primary key AUTOINCREMENT, full_name text, last_name text)
""")
self.conn.commit()
print('CREATE TABLE DONE')
except Exception as e:
print('ERROR')
#b = base('users')
#b.create_table()
#for x in range(1,4):
# b.insert(f'full_name{x}',f'last_name{x}')
#x = b.select()
#print(x)