import datetime
total_time = datetime.timedelta()
lst = ["00:33:33", "00:23:34", "01:32:21"]
for time in lst:
hours, minutes, seconds = time.split(":")
hours, minutes, seconds = int(hours), int(minutes), int(seconds)
total_time += datetime.timedelta(hours=hours, minutes=minutes, seconds=seconds)
print(total_time)
def midel(numbers):
numbers = [int(number) for number in numbers]
return sum(numbers) / len(numbers)
numbers = input("Введите цифры через пробел: ")
numbers = numbers.split(" ")
result = midel(numbers)
print(f"Результат: {result}")
Введите цифры через пробел: 2 2 2 2
Результат: 2.0
def command(**kwargs):
def wrapper(func_ref):
func_ref.command_kwargs = kwargs
return func_ref
return wrapper
class Aliases:
def __init__(self, bot: Bot):
self.bot = bot
@property
def commands(self) -> tuple:
return (
self.new_alias,
)
@command(
name="новый алиас",
args={"алиас": "str"}
)
def new_alias(self, message: types.Message = None):
...
def setup(bot: Bot, dp: Dispatcher):
aliases = Aliases(bot)
for function in aliases.commands:
print(function, function.command_kwargs)
<\bound method Aliases.new_alias of <\aliases.py.Aliases object at 0x7f4b0d0c2560>> {'name': 'новый алиас', 'args': {'алиас': 'str'}}
@bot.event
async def on_message(message):
if "привет" in str(message).lower():
await message.channel.send("Привет, друг")
@bot.event
async def on_message(message):
if "привет" in str(message.content).lower():
await message.channel.send("Привет, друг")
@bot.command()
async def grole(ctx):
import io
username = ctx.author
channel = bot.get_channel(id=111111111111111111)
for attach in ctx.message.attachments:
imgn = attach.filename
img = io.BytesIO(await attach.read())
await channel.send(file = discord.File(img, imgn))