from sympy import sympify, SympifyError
def show_error(error=None):
if error is not None:
print(f'ошибка {error}')
else:
print(f'ошибка')
def calculate():
try:
print(f'result: {sympify(input("ввод: "))}')
except SympifyError:
show_error()
except NameError:
show_error()
except TypeError:
show_error()
except Exception as e:
show_error(e)
while True:
calculate()
# | articles | categories
————————————-————————————-
1 | article_1 | category_1
2 | article_1 | category_2
3 | article_1 | category_3
from bs4 import BeautifulSoup
data = '''
<td class="p3">
<div data-tooltip='QWERTY' class='ToolTip'>12345</div>
</td>'''
soup = BeautifulSoup(data,'html.parser')
div = soup.find('div') # тут вы уж сами найдите нужный вам div, я просто моделирую типа мы его нашли.
tag = 'data-tooltip'
print(div.attrs[tag])
'prodolzhit' == 'v'
prodolzhit- назовите её
cont(contunue не надо, это используется в языке).
while True:
import re
def split_by_pattern(string, pattern):
return list(filter(None, re.sub(pattern, r'@@\1', string).split('@@')))
if __name__ == '__main__':
data = '''28.03.22, ПН
08:30 - 10:00 Предмет_1
10:10 - 11:40 Предмет_2
29.03.22, ВТ
08:30 - 10:00 Предмет_1
10:10 - 11:40 Предмет_2'''
my_pattern = r'(([\d]{2}\.){2}[\d]{2})'
print(split_by_pattern(data, my_pattern))
items = [] # Пустой список
for nomination, state in btn_ass.items():
items.insert(0,MyButtons(nomination, state)) # добавляю в список
print(items[0].state)
import requests
import xlrd
from pathlib import Path
def my_xml(citype, oldname, newname):
return f'''<?xml version='1.0' encoding='UTF-8'?>
<API version='1.0' >
<citype>
<name>{citype}</name>
<criterias>
<criteria>
<parameter>
<name compOperator="IS">CI Name</name>
<value>{oldname}</value>
</parameter>
</criteria>
</criterias>
<newvalue>
<record>
<parameter>
<name>CI Name</name>
<value>{newname}</value>
</parameter>
</record>
</newvalue>
</citype>
</API>'''
if __name__ == '__main__':
datafilename = Path('data.xls')
datafilepath = Path.home() / Path('Documents/Pytest/')
datafile = datafilepath / datafilename
book = xlrd.open_workbook(datafile)
sh = book.sheet_by_index(0)
url_prefix = "http://qwerty.com/api/ci?OPERATION_NAME=update&INPUT_DATA="
for i in range(0, sh.nrows):
print(f'## Итерация номер {i} из {sh.nrows}.')
oldname = str(sh.cell_value(rowx=i, colx=0))
citype = str(sh.cell_value(rowx=i, colx=1))
newname = str(sh.cell_value(rowx=i, colx=2))
url = url_prefix + my_xml(oldname, citype, newname)
requests.post(url)
data = '''[auth][22.03 11:33:40] help
[auth][22.03 11:33:42] i'am admin
[auth][22.03 11:34:00] proceed command
[auth][22.03 11:34:04] Replied to question
[auth][22.03 11:34:05] txt
[auth][22.03 11:34:26] txt
[auth][22.03 11:34:26] Aboba
[auth][22.03 11:34:29] Replied to question
[auth][22.03 11:34:37] text'''
requested_string = 'Replied to question'
[print(line) for line in data.splitlines() if requested_string in line]
print('hello' in 'hello world')
python3 setup.py install
Кто подскажет, где моя ошибка?
import sqlite3
sql = sqlite3.Connection('enter.db')
c = sql.cursor()
print('Подключение к базе данных проведено успешно!')
c.execute("""CREATE TABLE IF NOT EXISTS users (userlogin TEXT, password INTEGER, cash INTEGER)""")
sql.commit()
userlogin = input('Логин: ')
password = input('Пароль: ')
c.execute("SELECT userlogin FROM users where (?)", (userlogin,))
if c.fetchone() is None:
c.execute('INSERT INTO users VALUES (?, ?, ?)', (userlogin, password, 0))
sql.commit()
else:
print('Такой логин уже занят')
c.execute("SELECT * FROM users")
print(c.fetchall())