如何打印此命令中的随机数?

2024-04-26 04:49:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在用python写一个电报机器人。我要打印此命令中文本之间的随机数(从1到9,4位数):

import random
import telebot
from telebot.types import Message

TOKEN = ''

bot = telebot.TeleBot(TOKEN)

@bot.message_handler(commands=['start'])
def command_handler(message: Message):
    bot.reply_to(message, 'example_text1\n'
                          random_number_here\n
                          'example_text2\n')

我该怎么做?也许我可以用另一个命令,但我不知道怎么做。你知道吗


Tags: from文本import命令tokenmessageexamplebot