TELEGRAM_REG_CHAT_ID="1949275XX"
TELEGRAM_REG_CHAT_ID="-1949275XX"
STATUS_OK = 200
url = 'https://www.avito.ru/moskva/avtomobili?p={page}&radius=100'
page = 1
status = 200
while status == STATUS_OK:
response = requests.get(url.format(page=page))
if response.status_code == STATUS_OK:
page += 1
print("Working...")
else:
status = response.status_code
print("Всего страниц: ", page)
isdir()
нужен полный путь. Исходный вариант будет работать только для каталога, в котором лежит скрипт. Так будет работать:import os
path = '..'
for element in os.listdir(path):
if os.path.isdir(os.path.join(path, element)):
print(f'{element} - Это директория')
else:
print(f'{element} - Это не директория')
message = (
'Possible answers: link - change other link\n'
'py - start pycharm and open explorer\n'
'web - start sublime text and open study video'
)
print(message)
from collections import OrderedDict
a = {2: {"str1": "str", "str2": "str"}, 1: {"str1": "str", "str2": "str"}, 3: {"str1": "str", "str2": "str"}}
b = OrderedDict(sorted(a.items()))
print(b)
# OrderedDict([(1, {'str1': 'str', 'str2': 'str'}), (2, {'str1': 'str', 'str2': 'str'}), (3, {'str1': 'str', 'str2': 'str'})])
await types.ChatActions.upload_photo()
media = types.MediaGroup()
media.attach_photo(types.InputFile('data/cat.jpg'), 'Cat!')
media.attach_photo(types.InputFile('data/cats.jpg'), 'More cats!')
media.attach_photo('http://lorempixel.com/400/200/cats/', 'Random cat.')
await message.reply_media_group(media=media)
for i in list_directory:
print('Начинаем обработку файла:', i)
wb = openpyxl.load_workbook(i)
ws = wb.active
print (wb.sheetnames)
for sheet in wb:
sheet.oddHeader.left.text = ""
sheet.oddHeader.center.text = ""
sheet.oddHeader.right.text = ""
sheet.oddFooter.left.text = ""
sheet.oddFooter.center.text = ""
sheet.oddFooter.right.text = ""
print('save all changes')
wb.save(i)
print (wb.sheetnames)
def foo(a: ..., b: int) -> ...
def foo(a: any, b: int) -> ...
def bar():
...
def foo():
pass
def f(*args):
for i in args[0]:
print(i)
f([1, 2, 3, 4, 5])
def f(*args):
for i in args:
print(i)
f(1, 2, 3, 4, 5)
def f(*args):
for i in args:
print(i)
f(*[1, 2, 3, 4, 5])