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())
def fb(i: int, number_: int, fb_dict_: list) -> str:
"""
:param i:
:param number_:
:param fb_dict_:
:return:
"""
return str(fb_dict_[i % number_][number_])
def fb_calc(size: int, _numbers: tuple, _fb_dict: list):
"""
:param size:
:param _numbers:
:param _fb_dict:
"""
a, b = _numbers
for i in range(size):
print(''.join({fb(i, a, _fb_dict), fb(i, b, _fb_dict)}) or i)
if __name__ == '__main__':
numbers = (3, 13)
fb_size = 1000000
non_fb = {numbers[0]: '', numbers[1]: ''}
fb_dict = [{numbers[0]: 'fizz', numbers[1]: 'buzz'}]
for j in range(max(numbers)):
fb_dict.append(non_fb)
fb_calc(fb_size, numbers, fb_dict)
print(''.join({fb(i, a, _fb_dict), fb(i, b, _fb_dict)}) or i)
author = ctx.message.author
правильное обращение к искомому объекту? .author - это случайно не метод, который вы вызываете как параметр? Проверьте тип возвращаемого объекта, точно ли строка?