Ich versuche, Nachrichten an eine Telegram-Gruppe zu senden. Dazu verwende ich:main.py
....
import listings as list
....
from utils import *
utils.py
async def send_message_TEST():
chat_id='some_chat_id'
message_text = list.TEST
await bot.send_message(chat_id=chat_id, text=message_text, parse_mode="HTML")
async def send_message_RULES():
chat_id='some_chat_id'
message_text = list.RULES
await bot.send_message(chat_id=chat_id, text=message_text, parse_mode="HTML")
async def send_message_TABLE():
chat_id='some_chat_id'
message_text = list.TABLE
await bot.send_message(chat_id=chat_id, text=message_text, parse_mode="HTML")
listings.py
TEST = 'some text for tests'
RULES = 'Two lines text\n\n' \ 'Second line\n\n' \
TABLE = 'one more'
und diesen Fehler erhalten:
Dec 23 15:14:00 p6539.kvmvps python3.12[494]: ERROR:apscheduler.executors.default:Job "send_message_TEST (trigger: cron[hour='15', minute='14'], next run at: 2024-12-24 15:14:00)" raised an exception
Dec 23 15:14:00 p6539.kvmvps python3.12[494]: Traceback (most recent call last):
Dec 23 15:14:00 p6539.kvmvps python3.12[494]: File "/root/bot/venv/lib/python3.12/site-packages/apscheduler/executors/base.py", line 181, in run_coroutine_job
Dec 23 15:14:00 p6539.kvmvps python3.12[494]: retval = await job.func(*job.args, **job.kwargs)
Dec 23 15:14:00 p6539.kvmvps python3.12[494]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Dec 23 15:14:00 p6539.kvmvps python3.12[494]: File "/root/bot/utils.py", line 3, in send_message_TEST
Dec 23 15:14:00 p6539.kvmvps python3.12[494]: message_text = list.TEST
Dec 23 15:14:00 p6539.kvmvps python3.12[494]: ^^^^^^^^^
Dec 23 15:14:00 p6539.kvmvps python3.12[494]: AttributeError: type object 'list' has no attribute 'TEST'
Versuchen Sie (), [] – ohne Ergebnis
Anfänger Basict Python: AttributeError: Das Objekt „Liste“ hat kein Attribut beim Einschließen [Duplikat] ⇐ Python
-
- Similar Topics
- Replies
- Views
- Last post